NextPrime (Float function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
{{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.
This [[Intrinsic classes|intrinsic]] function returns the next [http://en.wikipedia.org/wiki/Prime_number prime number] after the method object value.


The NextPrime function is available as of version 7.3 of the [[Sirius Mods]].
The NextPrime function is available as of version 7.3 of the [[Sirius Mods]].
===NextPrime syntax===
==Syntax==
  %value = number:NextPrime
{{Template:Float:NextPrime syntax}}
====Syntax terms====
===Syntax terms===
<dl>
<dl>
<dt>%value
<dt>%value
Line 11: Line 13:
<dd>A Float value.
<dd>A Float value.
</dl>
</dl>
===Usage Notes===
==Usage notes==
*The method object value is initially rounded to the nearest integer before the next prime is determined.
*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.
*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 2<sup>31</sup>-1, the request is cancelled.
*If ''number'' is a negative value or is greater than 2<sup>31</sup>-1, the request is cancelled.
===Examples===
==Examples==
The following request displays the first one hundred prime numbers after 1000:
The following request displays the first one hundred prime numbers after 1000:
     b
     b

Revision as of 13:42, 19 January 2011

Find smallest prime greater than this number (Float class)


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

The NextPrime function is available as of version 7.3 of the Sirius Mods.

Syntax

%number = float:NextPrime

Syntax terms

%value
A numeric variable to receive the method result.
number
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.

Examples

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

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

See also

List of intrinsic Float methods