Function Repository Resource:

# RandomDotOrgInteger

Generate a random integer using the random.org service

Contributed by: Jan Mangaldan
 ResourceFunction["RandomDotOrgInteger"][{imin,imax}] gives a random integer in the range {imin,imax} using the random.org service. ResourceFunction["RandomDotOrgInteger"][imax] gives a random integer in the range {0,…,imax}. ResourceFunction["RandomDotOrgInteger"][] randomly gives 0 or 1. ResourceFunction["RandomDotOrgInteger"][range,n] gives a list of n random integers. ResourceFunction["RandomDotOrgInteger"][range,{n1,n2,…}] gives an n1×n2×… array of random integers.

## Details and Options

random.org is a true random number service that generates randomness via atmospheric noise, which for many purposes is better than the pseudorandom number algorithms typically used in computer programs.
ResourceFunction["RandomDotOrgInteger"] gives a different sequence of random integers whenever it is evaluated.
It is more efficient to generate multiple random numbers in a single call (e.g. ResourceFunction["RandomDotOrgInteger"][range,n]) instead of generating them one at a time (e.g. Table[ResourceFunction["RandomDotOrgInteger"][range],{n}]).

## Examples

### Basic Examples (5)

A random integer in the range 1 through 10:

 In[1]:=
 Out[1]=

A random integer in the range 0 through 3:

 In[2]:=
 Out[2]=

A random choice of 0 or 1:

 In[3]:=
 Out[3]=

Twenty random integers in the range 0 through 5:

 In[4]:=
 Out[4]=

A 3×4 random array of 0s and 1s:

 In[5]:=
 Out[5]=

### Applications (4)

A cellular automaton with random initial conditions:

 In[6]:=
 Out[6]=

Random circles at integer positions:

 In[7]:=
 Out[7]=

Random array of black and white cells:

 In[8]:=
 Out[8]=

Count how many pairs of random integers between 1 and a million are relatively prime:

 In[9]:=
 Out[9]=

### Possible Issues (1)

Integers outside the range {-109,109} cannot be generated:

 In[10]:=
 Out[10]=

### Neat Examples (1)

A randomly filled cubic lattice:

 In[11]:=
 Out[11]=

## Version History

• 1.0.0 – 09 January 2023

## Author Notes

The implementation is adapted from https://tpfto.wordpress.com/2012/05/15/using-the-random-org-generator-in-mathematica/