nextprime -- the next prime
number
Introductionnextprime(m) returns the smallest prime
number larger than or equal to m.
Call(s)nextprime(m)
Parametersm |
- | an arithmetical expression |
Returnsa prime number or a symbolic call to nextprime.
Related
Functionsifactor, igcd, ilcm, isprime, ithprime, numlib::prevprime
Detailsm is an integer, then
nextprime returns the smallest prime number larger than or
equal to m. A symbolic call of type
"nextprime" is returned, if the argument is not of type
Type::Numeric. An error
occurs if the argument is a number that is not an integer.nextprime is a function of the system kernel.
Example
1The first prime number is computed:
>> nextprime(-13)
2
If the argument of nextprime is a prime
number, this number is returned:
>> nextprime(11)
11
We compute a large prime:
>> nextprime(56475767478567)
56475767478601
Symbolic arguments lead to a symbolic call:
>> nextprime(x)
nextprime(x)
Backgroundnextprime uses a fast probabilistic prime number test
(Miller-Rabin test) to decide if the computed result is a prime number.
The result returned by nextprime is either a prime number
or a strong pseudo-prime for 10 randomly chosen bases.