Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Data Manipulation > Statistical Data Analysis > Random Number Generation > RandomPrime >
Mathematica > Mathematics and Algorithms > Mathematical Functions > Random Number Generation > RandomPrime >
Mathematica > Mathematics and Algorithms > Statistical Data Analysis > Random Number Generation > RandomPrime >

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:
In[1]:=
Click for copyable input
Out[1]=
 
A random 10-digit prime:
In[1]:=
Click for copyable input
Out[1]=
 
A list of 10 pseudorandom primes less than 100:
In[1]:=
Click for copyable input
Out[1]=
Generate a random array of primes less than 11 of dimension 4×5:
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
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF