Function Repository Resource:

RandomComposite (1.0.0) current version: 1.0.1 »

Source Notebook

Find a random composite number or set of random composite numbers

Contributed by: Peter Cullen Burbery

ResourceFunction["RandomComposite"][n]

returns a random composite number up to n.

ResourceFunction["RandomComposite"][n,m]

returns m random composite numbers up to n.

ResourceFunction["RandomComposite"][{min,max}]

returns a random composite number between min and max.

ResourceFunction["RandomComposite"][n, arrayspec]

returns an array of random composite numbers up to n.

Details

RandomComposite can return duplicates.

Examples

Basic Examples (2) 

Find a random composite number less than or equal to the a ceiling of the exponential of an integer:

In[1]:=
ResourceFunction["RandomComposite"][55]
Out[1]=

Find a random composite number between 149 and 404:

In[2]:=
ResourceFunction["RandomComposite"][{149, 404}]
Out[2]=

Scope (5) 

Find a list of 30 random composite numbers between 1097 and 2981:

In[3]:=
ResourceFunction["RandomComposite"][{1097, 2981}, 30]
Out[3]=

Find a 3⨯3 matrix of random composite numbers between 8104 and 22027 and print it in matrix form:

In[4]:=
ResourceFunction["RandomComposite", ResourceVersion->"1.0.0"][{8104, 22027}, {3, 3}] // MatrixForm
Out[4]=

Find a 3⨯3⨯3 array of random composite numbers between 59875 and 162755 and print it in matrix form:

In[5]:=
ResourceFunction["RandomComposite", ResourceVersion->"1.0.0"][{59875, 162755}, {3, 3, 3}] // MatrixForm
Out[5]=

Find a 3⨯3⨯3⨯3 tensor of random composite numbers between 442414 and 1202605:

In[6]:=
ResourceFunction["RandomComposite", ResourceVersion->"1.0.0"][{59875, 162755}, {3, 3, 3, 3}] // MatrixForm
Out[6]=

Find a large random composite up to a googol:

In[7]:=
ResourceFunction["RandomComposite"][10^100]
Out[7]=

Publisher

Peter Burbery

Version History

  • 1.0.1 – 28 July 2023
  • 1.0.0 – 06 June 2023

Related Resources

License Information