NextPrime (Float function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (match syntax diagram to template; fix tags and links)
Line 1: Line 1:
{{Template:Float:NextPrime subtitle}}
{{Template:Float:NextPrime subtitle}}


This [[Intrinsic classes|intrinsic]] function returns the next [http://en.wikipedia.org/wiki/Prime_number prime number] after the method object value.
The <var>NextPrime</var> <var>[[Intrinsic classes|intrinsic]]</var> function returns the next [http://en.wikipedia.org/wiki/Prime_number prime number] after the method object value.


The <var>NextPrime</var> function is available as of version 7.3 of the <var class=product>Sirius Mods</var>.
==Syntax==
==Syntax==
{{Template:Float:NextPrime syntax}}
{{Template:Float:NextPrime syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%value</th>
<tr><th>%number</th>
<td>A numeric variable to receive the method result. </td></tr>
<td>A numeric variable to receive the method result. </td></tr>
<tr><th>number</th>
<tr><th>float</th>
<td>A <var>Float</var> value.</td></tr>
<td>A <var>Float</var> value.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
*The method object value is initially rounded to the nearest integer before the next prime is determined.
<ul><li>The method object value is initially rounded to the nearest integer before the next prime is determined.
*<var>NextPrime</var> always returns a value higher than the method object value, even if the method object value is prime.
<li><var>NextPrime</var> always returns a value higher than the method object value, even if the method object value is prime.
*If ''number'' is a negative value or is greater than 2<sup>31</sup>-1, the request is cancelled.
<li>If ''number'' is a negative value or is greater than 2<sup>31</sup>-1, the request is cancelled.
<li><var>NextPrime</var> is available as of <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.3.</ul>
 
==Examples==
==Examples==
The following request displays the first one hundred prime numbers after 1000:
<ol><li>The following request displays the first one hundred prime numbers after 1000:
<p class="code">b
<p class="code">begin
%i    is float
  %i    is float
%n    is float
  %n    is float
%n = 1000
  %n = 1000
for %i from 1 to 100
  for %i from 1 to 100
  %n = %n:nextPrime
      %n = %n:nextPrime
  [[PrintText statement|printText]] {%n}
      [[PrintText statement|printText]] {%n}
end for
  end for
end
end
</p>


</p>
==See also==
==See also==
{{Template:Float:NextPrime footer}}
{{Template:Float:NextPrime footer}}

Revision as of 05:34, 4 February 2011

Find smallest prime greater than this number (Float class)


The NextPrime intrinsic function returns the next prime number after the method object value.

Syntax

%number = float:NextPrime

Syntax terms

%number A numeric variable to receive the method result.
float A Float value.

Usage notes

  • The method object value is initially rounded to the nearest integer before the next prime is determined.
  • NextPrime always returns a value higher than the method object value, even if the method object value is prime.
  • If number is a negative value or is greater than 231-1, the request is cancelled.
  • NextPrime is available as of "Sirius Mods" Version 7.3.

Examples

  1. The following request displays the first one hundred prime numbers after 1000:

    begin %i is float %n is float %n = 1000 for %i from 1 to 100 %n = %n:nextPrime printText {%n} end for end

    See also