This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

RandomPrime

 RandomPrime gives a pseudorandom prime number in the range to . RandomPrime gives a pseudorandom prime number in the range 2 to . RandomPrime gives a list of n pseudorandom primes.
• A random prime is computed by repeatedly generating pseudorandom integers in the specified range until the desired number of primes has been produced.
• If no prime exists in the specified range, the input is returned unevaluated with an error message.
• RandomPrime chooses primes between and with equal probability.
A random prime less than 100:
A random 10-digit prime:
A list of 10 pseudorandom primes less than 100:
A random prime less than 100:
 Out[1]=

A random 10-digit prime:
 Out[1]=

A list of 10 pseudorandom primes less than 100:
 Out[1]=
 Scope   (1)
Generate a random array of primes less than 11 of dimension 4×5:
 Applications   (1)
Find two large primes for use in RSA encryption:
This is a 640-binary-digit number:
Its binary representation:
Sampling of primes from 1 to 100:
The distribution is uniform over the primes:
If no prime exists in the specified range, an error message is returned:
New in 6