2015
Ulam Spiral Hidden
Patterns & Waves
Author: Mohammad Hefny
Ulam Spiral Hidden Patterns
Page 1 of 15
Contents Abstract: .......................................................................................................................................... 2
Numbers & Divisors Dependency ................................................................................................ 3
An OEN number can have 4 states: ......................................................................................... 4
An SVEN number can have 3states: ........................................................................................ 6
An NEIN number can have 4 states: ........................................................................................ 6
Divisors Waves............................................................................................................................. 7
List of All Waves: ..................................................................................................................... 9
A Hint on Waves Formula ...................................................................................................... 10
Ulman Spiral Pattern Explained ................................................................................................. 11
Conclusion ..................................................................................................................................... 14
References ..................................................................................................................................... 15
Ulam Spiral Hidden Patterns
Page 2 of 15
Abstract:
The Ulam spiral visualization method of prime numbers reveals some patterns and relations that
can be spotted by eye, whoever no formula can link between all prime numbers locations in this
diagram.
In Figure 1, black dots are prime numbers while white area is non-prime dots that are clustered
together. We can see in above diagram some discontinued diagonal lines formed by black dots
i.e. prime numbers.
In this study, focus will be made on white area rather than back dots. As this article suggests, the
tendency of forming diagonal lines of prime numbers are only the negative image of hidden
patterns exist in the white area.
Figure 1: Ulam Spiral Diagram
Ulam Spiral Hidden Patterns
Page 3 of 15
Numbers & Divisors Dependency
As per definition a prime number is a natural number greater than 1 that has no positive
divisors other than 1 and itself.
We will classify all numbers either prime or non-prime by its last digit to:
a. OEN: For numbers ended by 1 – will be called Ones-Ended Numbers
This set of numbers can be described as:
(10N +1) where N ε {1,2,3,….}
N represents the index –or order- of the number. For example index =0 is 1 and index =
1 is 11 and index = 2 is 21.
b. TREN: For numbers ended by 3 – will be called Three-Ended Numbers
This set of numbers can be described as:
(3N +1) where N ε {1,2,3,….}
N represents the index –or order- of the number. For example index =0 is 3 and index =
1 is 13 and index = 2 is 23.
c. SVEN: For numbers ended by 7 – will be called Seven-Ended Numbers
This set of numbers can be described as:
(10N +7) where N ε {1,2,3,….}
N represents the index –or order- of the number. For example index =0 is 7 and index =
1 is 17 and index = 2 is 27.
d. NIEN: For numbers ended by 9 – will be called Nine-Ended Numbers
This set of numbers can be described as:
(10N +9) where N ε {1,2,3,….}
Figure 2: Classifying numbers by last digit
Ulam Spiral Hidden Patterns
Page 4 of 15
N represents the index –or order- of the number. For example index =0 is 9 and index =
1 is 19 and index = 2 is 29.
We will just ignore even numbers and numbers ended by five as they all non-prime except 2 & 5,
as all even numbers have 2 as a positive divisor and all five-ended numbers have 5 as a positive
divisor.
An OEN number can have 4 states:
a. To have a positive two divisors, both are OEN such as 121, 341 …etc.
b. To have a positive two divisors, one is TREN & the second should be SVEN such as
21, 51, 91 …etc.
c. To have a positive two divisors, both are NIEN such as 81, 171 …etc.
d. If not one of the above then the number is a prime number that is ended by 1. Such
as 1,11,31,41.
OEN of the first state can be describes as:
(10N + 1) * (10M + 1) = (10L + 1) where N,M,L ε {1,2,3,….} eq.1
again N, M & L are indices of numbers all ended by 1 i.e. OEN.
OEN of the second state can be describes as:
(10N + 3) * (10M + 7) = (10L + 1) where N,M,L ε {1,2,3,….} eq.2
N is an index of a TREN number , M is an index of a SVEN number while L is an index of
OEN number.
OEN of the third state can be describes as:
(10N + 9) * (10M +9) = (10L + 1) where N,M,L ε {1,2,3,….} eq.3
N, M are indices of NIEN numbers while L is an index of OEN number.
Now the forth state which is prime numbers that are ended by 1. Cannot be described using a
formula. They are the numbers that remains in OEN set after taking out the three other states.
Ulam Spiral Hidden Patterns
Page 5 of 15
Same technique can be applied on TRED, SVEN & NEIN numbers.
Figure 3: Bright dots are NON-PRIME OEN numbers
Ulam Spiral Hidden Patterns
Page 6 of 15
An TRED number can have 3 states:
a. To have a positive two divisors, one is TREN & the second should be OEN such as 33,
143 …etc.
(10N + 1) * (10M + 3) = (10L + 3) where N,M,L ε {1,2,3,….} eq.4
b. To have a positive two divisors, one is SVEN & the second should be NEIN such as
63, 133, 153 …etc.
(10N + 7) * (10M + 9) = (10L + 3) where N,M,L ε {1,2,3,….} eq.5
c. If not one of the above then the number is a prime number that is ended by 3. Such
as 3, 13, 23, 43 …etc.
An SVEN number can have 3states:
a. To have a positive two divisors, one is SVEN & the second should be OEN such as 77,
187, 217 …etc.
(10N + 7) * (10M + 1) = (10L + 7) where N,M,L ε {1,2,3,….} eq.6
b. To have a positive two divisors, one is TREN & the second should be NEIN such as
27, 57, 117 …etc.
(10N + 3) * (10M + 9) = (10L + 7) where N,M,L ε {1,2,3,….} eq.7
c. If not one of the above then the number is a prime number that is ended by 7. Such
as 7, 17, 37 …etc.
An NEIN number can have 4 states:
a. To have a positive two divisors, both are TREN such as 9, 39, 169 …etc.
(10N + 3) * (10M + 3) = (10L + 9) where N,M,L ε {1,2,3,….} eq.8
b. To have a positive two divisors, one is OEN & the second should be NIEN such as
209, 319, 589 …etc.
(10N + 1) * (10M + 9) = (10L + 9) where N,M,L ε {1,2,3,….} eq.9
c. To have a positive two divisors, both are SVEN such as 49, 119, 629 …etc.
(10N + 7) * (10M + 7) = (10L + 9) where N,M,L ε {1,2,3,….} eq.10
d. If not one of the above then the number is a prime number that is ended by 9. Such
as 19, 29, 59, 79 …etc.
Ulam Spiral Hidden Patterns
Page 7 of 15
Divisors Waves
There are two reasons behind why prime numbers are not distributed uniformly:
1- Prime numbers ended with 1 and 3 and 7 & 9 are all handled together as if they were
related, while there are not. i.e. there is no relation between 13 & 19.
2- Taking numbers ends with 1 OEN:
a. Non prime numbers as defined above “Stated of OEN Numbers” are controlled
by three equations eq. 1, & eq.2 & eq.3 and these equations are not dependent
on each others.
If we study these multiples and there intersections with numbers ends with 1 axis, we will find it
as waves each wave has a wave length and a phase.
Let us start by numbers ended by 1.
The pattern is described as a start –phase- and a length –wave length-. The start is given as
number index i.e. for number (10L +1) L is the number index.
The patterns are
a. (1,11) , (2,21), (3,31) …… ( n , (10n + 1)) pattern 1
b. (2,3) , (9,13), (16,33) ……. ( 7n + 2 , (10n + 3)) pattern 2
c. (8,9), (17,19), (26,29) …… ( 9n + 8 , (10n + 9)) pattern 3
Ulam Spiral Hidden Patterns
Page 8 of 15
What we see here is read as follows: There is a wave start at index 1 which is number “11” and
replicated every 11’th index which means at index 1 + 11 = index 12 = number 121, and index 1
+ 11 + 11 = index 23 = number 231 ….etc. this is only generated from (1,11).
Same technique for (2,21) the first number is index 2 = number 21 and the second is index 23 =
231 and the third number is index 44 = number 441 and they are all can be divided by 21 the
original wave phase “the index 2”.
It is logic to say that these
Only in pattern 1 the start point in the pattern is a Prime Number, unless it exists in pattern 2 or
pattern 3. For example 21 is prime for pattern 1 but could be reached by pattern 2 in (2,3)
where 2 is the index number of 21.
In another way, any prime number is a start of a wave with a length of is value, for example 11
starts a wave from prime_index 1 with wave length = 11. In case of number 21 it is the same,
but it is hit by a wave comes from 3.
Ulam Spiral Hidden Patterns
Page 9 of 15
Another interesting thing that is logic to expect is the symmetric in above table for values 1 x 1
& 9 x 9 where for numbers ended by 3 & 7 it is not symmetric.
List of All Waves:
OEN Waves:
Start Point Wave Length or Step Examples
N 10 * N + 1 (121,231,…) OEN x OEN
7 * N + 2 10 * N + 3 (21,51,…) TRED x SVEN
9 * N + 8 10 * N + 9 (81,171,361,…) NIEN x NIEN
N is index of a OEN number
TREN Waves:
Start Point Wave Length or Step Examples
N 10 * N + 3 (33,143,…) TRED x OEN
9 * N + 6 10 * N + 7 (63,133,153, …) SVEN x NIEN
N is index of a TRED number
SVEN Waves:
Start Point Wave Length or Step Examples
N 10 * N + 7 (77, 187, …) SVEN x OEN
9 * N + 2 10 * N + 3 (27, 57,…) TRED x NIEN
N is index of a SVEN number
NIEN Waves:
Start Point Wave Length or Step Examples
N 10 * N + 9 (99,189, 209,…) NEIN x OEN
3 * N 10 * N + 3 (39,169, …) TREN x TREN
7 * N + 4 10 * N + 7 (119,287, …) SVEN x SVEN
N is index of a NIEN number
Ulam Spiral Hidden Patterns
Page 10 of 15
A Hint on Waves Formula
Take wave result in multiplying SVEN number by TRED number to generate OEN non prime.
Wave is (7 * N + 2 , 10 * N + 3).
When substituting in this wave :
Use N =0
7 * N + 2 = 2 This is the first index which equals to number (10 * N + 1) = 21.
Then increment with step (10 * N + 3) => 2 , 2 + 3, 2 + 3 + 3 …etc. => 21, 51, 81 …..etc.
Then increment N by one to go to the second wave.
7 * N + 2 = 9 which is equal to number 91
Then increment with step (10 * N + 3) => 9 , 9 + 13, 9 + 13 + 13 …etc. => 21, 221, 351 …..etc.
NOTE: for OEN x OEN we skip the very first result as it could be prime, unless it is intersected
with a wave comes from TRED or SVEN.
Same done with TRED , SVEN & NIEN numbers.
These waves enable the generation of non-prime number in one step by substituting in N of the
desired formla. We will use these wave formulas to generate Ulma Spiral Diagram directly
without the need to use classical approach of using isPrime function.
Ulam Spiral Hidden Patterns
Page 11 of 15
Ulman Spiral Pattern Explained
As we can see in figure 5, even
numbers in Ulman spiral define a
well-formed pattern.
Again in figure 6 we can see a well-
formed pattern of numbers that are
multiples of 5. This by the way
including numbers ended by 0 which
are even numbers as well, so parts
of these patterns are overlapped.
Actually even if we remove 10’s
from figure 6, we will still get a
pattern, it is only a matter of
changing part of the patter into
black.
If we combine even numbers and
numbers ended by 5 in one
diagram as in figure 6 we can see
diagonal lines appear.
Now coming to less well-formed
patterns, they are patterns that can
be spotted in OEN, TRED, SVEN &
NEIN. There reason behind this is
that these set of numbers which
contains prime numbers in between,
and due to waves equations
mentioned above, waves
intersections that comes from other
sets helps to reduce the
homogeneity and continuity of the
pattern.
Figure 5: Red are even numbers.
Figure 4: Highlighted dots are numbers ended by 5 or 0. i.e. has 5 as a positive divisor
Ulam Spiral Hidden Patterns
Page 12 of 15
In figure 13,14,15,16 we started
added OEN, NIEN, TREN & SVEN in
order to data in figure 6.
Figure 8: Green dots are non-prime numbers ended by 3 Figure 7: Yellow dots are Non-Prime numbers ended by 7
Figure 6: Even & numbers ended by 5 are plotted in white.
Ulam Spiral Hidden Patterns
Page 13 of 15
Figure 10: A merge between Non-Prim TRED & SVEN. Figure 9: Purple dots are non-prime numbers ended by 9.
Figure 13: Adding OEN to Even & 5s Figure 14: OEN & NIEN added to even & 5's
Figure 12: Ulam Spiral Figure 11: OEN, TREN, NIEN added to even & 5's
Ulam Spiral Hidden Patterns
Page 14 of 15
Conclusion
Ulam Spiral can be generated without the need to have a list of prime numbers or test if a
number is a prime or not.
Diagonal patterns are due to non-prime even numbers, and non-prime numbers ended by 5.
OEN, TREN & NIEN sets have waves of multiplies with a defined formula , that can be used to
generate non-prime numbers without directly without the need to test if the generated number
is prime or not, or the need of generate these numbers in sequence. We can choose N as any
arbitrary positive integer and substitute in Wave formulas to get a non-prime number.
Adding non-prime (OEN, TREN, NIEN) numbers just make distortion to this pattern and that
gives the impression that prime numbers in Ulman Spiral are related together in lines. While it is
vice versa, even numbers and numbers ended by 5 create the pattern and prime number just
distorted it.
Python Script to Generate Ulam is here
https://www.dropbox.com/s/kl5fzccigl0132g/UlamSpiralGenerator.v1.py?dl=0
Ulam Spiral Hidden Patterns
Page 15 of 15
References
Prime Number Validator – Author Mohammad Hefny
http://www.slideshare.net/MHefny/prime-number-validator
Wikipedia (Ulam Spiral): http://en.wikipedia.org/wiki/Ulam_spiral
The Distribution of Prime Numbers on the Square Root Spiral - Authors Harry K. Hahn
http://arxiv.org/ftp/arxiv/papers/0801/0801.1441.pdf