I-th prime number
MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
ithprime(i) returns the
If the argument
i is a positive integer,
ithprime returns the
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.
The first prime number
ithprime(1) is 2.
i-th prime number is contained in
the system's internal prime number table (see the help page for
ifactor), then it is
returned by a fast kernel function. Otherwise, MuPAD® iteratively
using some suitable pre-computed value of
starting point. This is still reasonably fast for i ≤
i exceeds this
value, however, then the run time grows exponentially with the number
of digits of
The first 10 prime numbers:
ithprime(i) $ i = 1..10
A larger prime:
Symbolic arguments lead to an unevaluated call:
Return the number of primes in the internal prime table
Prime number or an unevaluated call to