Function Repository Resource:

# UlamMatrix

Generate the Ulam matrix

Contributed by: Jan Mangaldan
 ResourceFunction["UlamMatrix"][n] returns the n×n Ulam matrix.

## Details and Options

In an n×n Ulam matrix, the first n2 positive integers are arranged in a counterclockwise spiral pattern, starting from the middle.
ResourceFunction["UlamMatrix"][,WorkingPrecisionp] gives a matrix with entries of precision p.

## Examples

### Basic Examples (2)

A 5×5 Ulam matrix:

 In[1]:=
 Out[1]=

Visualize a large Ulam matrix:

 In[2]:=
 Out[2]=

Show the same matrix mod 7:

 In[3]:=
 Out[3]=

### Options (3)

#### WorkingPrecision (3)

By default, an exact matrix is computed:

 In[4]:=
 Out[4]=

Use machine precision:

 In[5]:=
 Out[5]=

Use arbitrary precision:

 In[6]:=
 Out[6]=

### Applications (2)

Mark the positions of prime numbers in the Ulam matrix and visualize the result:

 In[7]:=
 Out[7]=

Color numbers in the Ulam matrix by the number of their divisors:

 In[8]:=
 Out[8]=

## Version History

• 1.0.0 – 18 August 2023