ithprime -- the i-th
prime number
Introductionithprime(i) returns the i-th
prime number.
Call(s)ithprime(i)
Parametersi |
- | an arithmetical expression |
Returnsa prime number or an unevaluated call to ithprime
Related
Functionsifactor, igcd, ilcm, isprime, nextprime, numlib::prevprime
Detailsi is a positive integer, then
ithprime returns the i-th prime number. An
unevaluated call is returned, if the argument is not of type Type::Numeric. An error occurs if
the argument is a number that is not a positive integer.ithprime(1) is
2.ifactor), then it is returned by a
fast kernel function. Otherwise, MuPAD iteratively calls
nextprime, using
some suitable pre-computed value of ithprime as starting
point. This is still reasonably fast for i <= 1000000. If
i exceeds this value, however, then the run time grows
exponentially with the number of digits of i.
Example
1The first 10 prime numbers:
>> ithprime(i) $ i = 1..10
2, 3, 5, 7, 11, 13, 17, 19, 23, 29
A larger prime:
>> ithprime(123456)
1632899
Symbolic arguments lead to an unevaluated call:
>> ithprime(i)
ithprime(i)