This site is supported by donations to The OEIS Foundation.

# Ulam spiral

(Redirected from Ulam's spiral)

The Ulam spiral is an arrangement of numbers upon which the prime numbers tend to fall on certain diagonals. It may begin on any integer, and may be oriented a few different ways. But the version most commonly presented begins with 1 at the center, and takes its cue for orientation from the March 1964 cover of Scientific American, with 2 to the right of 1, and 3 above 2, so that the northern ray reads 1, 4, 15, 34...

## Original Ulam spiral

In the spiral, even numbers are shown in red, odd numbers in black and prime numbers are in bold.

 A053755: Numbers of the form ${\displaystyle 4n^{2}+1}$A121326: Primes of this form A054556: Numbers of the form ${\displaystyle 4n^{2}-9n+6}$A168023: Non-composites of this form A002378: Numbers of the form ${\displaystyle n(n+1)}$2 is the only even prime A054554: Numbers of the form ${\displaystyle 4n^{2}-10n+7}$A073337: Primes of this form A054567: Numbers of the form ${\displaystyle 4n^{2}-7n+4}$A168025: Non-composites of this form 65 64 63 62 61 60 59 58 57 A054552: Numbers of the form ${\displaystyle 4n^{2}-3n+1}$A168022: Non-composites of this form 66 37 36 35 34 33 32 31 56 67 38 17 16 15 14 13 30 55 68 39 18 5 4 3 12 29 54 69 40 19 6 1 2 11 28 53 70 41 20 7 8 9 10 27 52 71 42 21 22 23 24 25 26 51 72 43 44 45 46 47 48 49 50 73 74 75 76 77 78 79 80 81 A054569: Numbers of the form ${\displaystyle 4n^{2}-6n+3}$A168026: Non-composites of this form A033951: Numbers of the form ${\displaystyle 4n^{2}+3n+1}$A168027: Non-composites of this form A073577: Numbers of the form ${\displaystyle (2n+1)^{2}-2}$A028871: Primes of this form A016754: Odd squares, ${\displaystyle (2n+1)^{2}}$No primes of this form.

Stanislaw Ulam first studied this spiral in 1963, doodling "while sitting through a boring talk."[1] Other starting values can be used and the same clustering of primes along certain diagonals is also observed, such as starting with 41.[2]

## Odd numbers Ulam spiral

In the odd number variant of the Ulam spiral, unimpeded by the even numbers, the prime numbers can line up in horizontal and vertical lines. But there are still noticeable diagonal lines of primes, and these primes fall on one such diagonal.

 221 223 225 227 229 231 233 235 237 239 241 219 145 147 149 151 153 155 157 159 161 163 217 143 85 87 89 91 93 95 97 99 165 215 141 83 41 43 45 47 49 51 101 167 213 139 81 39 13 15 17 19 53 103 169 211 137 79 37 11 1 3 21 55 105 171 209 135 77 35 9 7 5 23 57 107 173 207 133 75 33 31 29 27 25 59 109 175 205 131 73 71 69 67 65 63 61 111 177 203 129 127 125 123 121 119 117 115 113 179 201 199 197 195 193 191 189 187 185 183 181

Note the diagonal of primes of the form ${\displaystyle \scriptstyle 8n^{2}-1\,}$ (Cf. A090684)

{7, 31, 71, 127, 199, 647, 967, 1151, 1567, 2311, 2591, 2887, 3527, 4231, 4999, 5407, 6271, 7687, 8191, 11551, 12799, 16927, 19207, 20807, 23327, 25087, 27847, 31751, 34847, 35911, ...}

Note the horizontal line of primes of the form ${\displaystyle \scriptstyle 8n^{2}+2n+1\,}$ (Cf. A188382)

{11, 37, 79, 137, 211, 821, 991, 1597, 1831, 2081, 2347, 2927, 3571, 3917, 4657, 5051, 6329, 8779, 9871, 11027, 14197, 14879, 17021, 20101, 21737, 26107, 27967, 28921, 33931, 34981, ...}

Note the vertical line of primes of the form ${\displaystyle \scriptstyle 8n^{2}+6n-1\,}$ (Cf. A187677)

{13, 43, 89, 151, 229, 433, 701, 859, 1033, 1223, 1429, 1889, 2143, 2699, 3001, 3319, 4003, 4751, 5563, 7873, 10009, 11173, 11779, 12401, 13693, 17203, 18719, 19501, 21943, 25423, ...}

## Ulam spiral with numbers congruent to 1 or 5 (mod 6)

 331 335 337 341 343 347 349 353 355 359 361 329 217 221 223 227 229 233 235 239 241 245 325 215 127 131 133 137 139 143 145 149 247 323 211 125 61 65 67 71 73 77 151 251 319 209 121 59 19 23 25 29 79 155 253 317 205 119 55 17 1 5 31 83 157 257 313 203 115 53 13 11 7 35 85 161 259 311 199 113 49 47 43 41 37 89 163 263 307 197 109 107 103 101 97 95 91 167 265 305 193 191 187 185 181 179 175 173 169 269 301 299 295 293 289 287 283 281 277 275 271

## Notes

1. D. Wells, Prime Numbers: The Most Mysterious Figures in Math Hoboken, New Jersey: John Wiley & Sons Inc. (2005) p. 232
2. Ibid., p. 233