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

# RandomInteger

 RandomIntegergives a pseudorandom integer in the range . RandomIntegergives a pseudorandom integer in the range . RandomIntegerpseudorandomly gives 0 or 1. RandomIntegergives a list of n pseudorandom integers. RandomIntegergives an ××... array of pseudorandom integers.
• RandomInteger chooses integers in the range with equal probability.
• RandomInteger gives a different sequence of pseudorandom integers whenever you run Mathematica. You can start with a particular seed using SeedRandom.
• A Method option to SeedRandom can be given to specify the pseudorandom generator used.
A random integer in the range 1 through 10:
A random integer in the range 0 through 3:
A random choice of 0 or 1:
20 random integers in the range 0 through 5:
A 3×4 random array of 0s and 1s:
A random integer in the range 1 through 10:
 Out[1]=

A random integer in the range 0 through 3:
 Out[1]=

A random choice of 0 or 1:
 Out[1]=

20 random integers in the range 0 through 5:
 Out[1]=

A 3×4 random array of 0s and 1s:
 Out[1]=
 Scope   (1)
Generate random integers of any size:
 Applications   (4)
A cellular automaton with random initial conditions:
Random circles at integer positions:
Random array of black and white cells:
Count how many pairs of random integers between 1 and a million are relatively prime:
Use SeedRandom to get repeatable random values:
Use BlockRandom to block one use of RandomInteger from affecting others:
RandomInteger generates a uniform distribution, here with mean 5:
A randomly filled cubic lattice:
New in 6