Primal Stream

It’s obvious when you think about: an even number can never be the sum of two consecutive integers. Conversely, an odd number (except 1) is always the sum of two consecutive integers: 3 = 1 + 2; 5 = 2 + 3; 7 = 3 + 4; 9 = 4 + 5; and so on. The sum of three consecutive integers can be either odd or even: 6 = 1 + 2 + 3; 9 = 2 + 3 + 4. The sum of four consecutive integers must always be even: 1 + 2 + 3 + 4 = 10; 2 + 3 + 4 + 5 = 14. And so on.

But notice that 9 is the sum of consecutive integers in two different ways: 9 = 4 + 5 = 2 + 3 + 4. Having spotted that, I decided to look for numbers that were the sums of consecutive integers in the most different ways. These are the first few:

3 = 1 + 2 (number of sums = 1)
9 = 2 + 3 + 4 = 4 + 5 (s = 2)
15 = 1 + 2 + 3 + 4 + 5 = 4 + 5 + 6 = 8 + 7 = (s = 3)
45 (s = 5)
105 (s = 7)
225 (s = 8)
315 (s = 11)
945 (s = 15)
1575 (s = 17)
2835 (s = 19)
3465 (s = 23)
10395 (s = 31)


It was interesting that the number of different consecutive-integer sums for n was most often a prime number. Next I looked for the sequence at the Online Encyclopedia of Integer Sequences and discovered something that I hadn’t suspected:

A053624 Highly composite odd numbers: where d(n) increases to a record.

1, 3, 9, 15, 45, 105, 225, 315, 945, 1575, 2835, 3465, 10395, 17325, 31185, 45045, 121275, 135135, 225225, 405405, 675675, 1576575, 2027025, 2297295, 3828825, 6891885, 11486475, 26801775, 34459425, 43648605, 72747675, 130945815 — A053624 at OEIS

The notes add that the sequence is “Also least number k such that the number of partitions of k into consecutive integers is a record. For example, 45 = 22+23 = 14+15+16 = 7+8+9+10+11 = 5+6+7+8+9+10 = 1+2+3+4+5+6+7+8+9, six such partitions, but all smaller terms have fewer such partitions (15 has four).” When you don’t count the number n itself as a partition of n, you get 3 partitions for 15, i.e. consecutive integers sum to 15 in 3 different ways, so s = 3. I looked at more values for s and found that the stream of primes continued to flow:

3 → s = 1
9 = 3^2 → s = 2 (prime)
15 = 3 * 5 → s = 3 (prime)
45 = 3^2 * 5 → s = 5 (prime)
105 = 3 * 5 * 7 → s = 7 (prime)
225 = 3^2 * 5^2 → s = 8 = 2^3
315 = 3^2 * 5 * 7 → s = 11 (prime)
945 = 3^3 * 5 * 7 → s = 15 = 3 * 5
1575 = 3^2 * 5^2 * 7 → s = 17 (prime)
2835 = 3^4 * 5 * 7 → s = 19 (prime)
3465 = 3^2 * 5 * 7 * 11 → s = 23 (prime)
10395 = 3^3 * 5 * 7 * 11 → s = 31 (prime)
17325 = 3^2 * 5^2 * 7 * 11 → s = 35 = 5 * 7
31185 = 3^4 * 5 * 7 * 11 → s = 39 = 3 * 13
45045 = 3^2 * 5 * 7 * 11 * 13 → s = 47 (prime)
121275 = 3^2 * 5^2 * 7^2 * 11 → s = 53 (prime)
135135 = 3^3 * 5 * 7 * 11 * 13 → s = 63 = 3^2 * 7
225225 = 3^2 * 5^2 * 7 * 11 * 13 → s = 71 (prime)
405405 = 3^4 * 5 * 7 * 11 * 13 → s = 79 (prime)
675675 = 3^3 * 5^2 * 7 * 11 * 13 → s = 95 = 5 * 19
1576575 = 3^2 * 5^2 * 7^2 * 11 * 13 → s = 107 (prime)
2027025 = 3^4 * 5^2 * 7 * 11 * 13 → s = 119 = 7 * 17
2297295 = 3^3 * 5 * 7 * 11 * 13 * 17 → s = 127 (prime)
3828825 = 3^2 * 5^2 * 7 * 11 * 13 * 17 → s = 143 = 11 * 13
6891885 = 3^4 * 5 * 7 * 11 * 13 * 17 → s = 159 = 3 * 53
11486475 = 3^3 * 5^2 * 7 * 11 * 13 * 17 → s = 191 (prime)
26801775 = 3^2 * 5^2 * 7^2 * 11 * 13 * 17 → s = 215 = 5 * 43
34459425 = 3^4 * 5^2 * 7 * 11 * 13 * 17 → s = 239 (prime)
43648605 = 3^3 * 5 * 7 * 11 * 13 * 17 * 19 → s = 255 = 3 * 5 * 17
72747675 = 3^2 * 5^2 * 7 * 11 * 13 * 17 * 19 → s = 287 = 7 * 41
130945815 = 3^4 * 5 * 7 * 11 * 13 * 17 * 19 → s = 319 = 11 * 29


I can’t spot any way of predicting when n will yield a primal s, but I like the way that a simple question took an unexpected turn. When a number sets a record for the number of different ways it can be the sum of consecutive integers, that number will also be a highly composite odd number.

Primal Stream

• 3, 7, 31, 127, 8191, 131071, 524287, 2147483647, 2305843009213693951, 618970019642690137449562111, 162259276829213363391578010288127, 170141183460469231731687303715884105727 — A000668, Mersenne primes (primes of the form 2^n – 1), at the Online Encyclopedia of Integer Sequences

• 2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, 30402457, 32582657, 37156667, 42643801, 43112609, 57885161, 74207281, 77232917, 82589933 — A000043, Mersenne exponents: primes p such that 2^p – 1 is prime. Then 2^p – 1 is called a Mersenne prime. […] It is believed (but unproved) that this sequence is infinite. The data suggest that the number of terms up to exponent N is roughly K log N for some constant K.

• The largest known prime number (as of May 2022) is 282,589,933 − 1, a number which has 24,862,048 digits when written in base 10. It was found via a computer volunteered by Patrick Laroche of the Great Internet Mersenne Prime Search (GIMPS) in 2018. — Largest known prime number

Magiciprocal


A021023 Decimal expansion of 1/19.

0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8 [...] The magic square that uses the decimals of 1/19 is fully magic. — A021023 at the Online Encyclopedia of Integer Sequences

1nf1nity

Here are the natural numbers or counting numbers:

• 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77... — A000027 at the Online Encyclopedia of Integer Sequences (OEIS)


Here are the prime numbers, or numbers divisible only by themselves and 1:

• 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271... — A000040 at the OEIS


Here are the palindromic prime numbers, or prime numbers that read the same both forwards and backwards:

• 2, 3, 5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929, 10301, 10501, 10601, 11311, 11411, 12421, 12721, 12821, 13331, 13831, 13931, 14341, 14741, 15451, 15551, 16061, 16361, 16561, 16661, 17471, 17971, 18181... — A002385 at the OEIS


Finally, here are the repunit primes, or palindromic primes consisting only of 1s:

• 11, 1111111111111111111, 11111111111111111111111, 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111, 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111... — A004022 at the OEIS (see A004023 for numbers of 1s in each repunit prime)


It’s obvious that there are more counting numbers than primes, isn’t it? Well, no. There are in fact as many primes as counting numbers. And there may be as many palindromic primes as primes. And as many repunit primes as palindromic primes.

Prime Times

The factorial of an integer is equal to that that integer multiplied by all the integers smaller than it. For example, this is factorial(7) or 7!:

7! = 7 * 6 * 5 * 4 * 3 * 2 * 1 = 5040

The primorial of a prime is equal to that that prime multiplied by all the primes smaller than it. For example, this is primorial(7):

primorial(7) = 7 * 5 * 3 * 2 = 210 = 4# (the product of the first four primes)

Here’s an interesting set of primorials incremented-by-one:

primorial(2) + 1 = 2 + 1 = 3 (prime)
primorial(3) + 1 = 2*3 + 1 = 7 (prime)
primorial(5) + 1 = 2*3*5 + 1 = 31 (prime)
primorial(7) + 1 = 2*3*5*7 + 1 = 211 (prime)
primorial(11) + 1 = 2*3*5*7*11 + 1 = 2311 (prime)
primorial(31) + 1 = 2*3*5*7*11*13*17*19*23*29*31 + 1 = 200560490131 (prime)
primorial(379) + 1 = 1,719,620,105,458,406,433,483,340,568,317,543,019,584,575,635,895,742,560,438,771,105,058,321,655,238,562,613,083,979,651,479,555,788,009,994,557,822,024,565,226,932,906,295,208,262,756,822,275,663,694,111 (prime)
primorial(1019) + 1 = 20,404,068,993,016,374,194,542,464,172,774,607,695,659,797,117,423,121,913,227,131,032,339,026,169,175,929,902,244,453,757,410,468,728,842,929,862,271,605,567,818,821,685,490,676,661,985,389,839,958,622,802,465,986,881,376,139,404,138,376,153,096,103,140,834,665,563,646,740,160,279,755,212,317,501,356,863,003,638,612,390,661,668,406,235,422,311,783,742,390,510,526,587,257,026,500,302,696,834,793,248,526,734,305,801,634,165,948,702,506,367,176,701,233,298,064,616,663,553,716,975,429,048,751,575,597,150,417,381,063,934,255,689,124,486,029,492,908,966,644,747,931 (prime)
primorial(1021) + 1 = 20,832,554,441,869,718,052,627,855,920,402,874,457,268,652,856,889,007,473,404,900,784,018,145,718,728,624,430,191,587,286,316,088,572,148,631,389,379,309,284,743,016,940,885,980,871,887,083,026,597,753,881,317,772,605,885,038,331,625,282,052,311,121,306,792,193,540,483,321,703,645,630,071,776,168,885,357,126,715,023,250,865,563,442,766,366,180,331,200,980,711,247,645,589,424,056,809,053,468,323,906,745,795,726,223,468,483,433,625,259,000,887,411,959,197,323,973,613,488,345,031,913,058,775,358,684,690,576,146,066,276,875,058,596,100,236,112,260,054,944,287,636,531 (prime)
primorial(2657) + 1 = 78,244,737,296,323,701,708,091,142,569,062,680,832,012,147,734,404,650,078,590,391,114,054,859,290,061,421,837,516,998,655,549,776,972,299,461,276,876,623,748,922,539,131,984,799,803,433,363,562,299,977,701,808,549,255,204,262,920,151,723,624,296,938,777,341,738,751,806,450,993,015,446,712,522,509,989,316,673,420,506,749,359,414,629,957,842,716,112,900,306,643,009,542,215,969,000,431,330,219,583,111,410,996,807,066,475,261,560,303,182,609,636,056,108,367,412,324,508,444,341,178,028,289,201,803,518,093,842,982,877,662,621,552,756,279,669,241,303,362,152,895,160,479,720,040,128,335,518,247,125,849,521,099,841,272,983,588,935,580,888,630,036,283,712,163,901,558,436,498,481,482,160,712,530,124,868,714,141,094,634,892,999,056,865,426,200,254,647,241,979,548,935,087,621,308,526,547,138,125,987,102,062,688,568,486,250,939,447,065,798,353,626,745,169,380,579,442,233,006,898
,444,700,264,240,321,482,823,859,842,044,524,114,576,784,795,294,818,755,525,169,192,652,108,755,230,262,128,210,258,672,754,900,845,837,728,345,782,457,465,793,874,408,469,588,052,577,208,643,754,019,053,756,394,151,041,512,099,598,925,557,724,343,099,264,685,155,934,891,439,161,866,250,113,047,185,553,511,797,406,764,115,907,248,713,405,817,594,729,550,600,082,808,324,331,387,143,679,800,355,356,811,873,430,669,962,333,651,282,822,030,473,702,042,073,141,618,450,021,084,993,659,382,646,598,194,115,178,864,433,545,186,250,667,775,794,249,961,932,761,063,071,117,967,553,887,984,011,652,643,245,393,971 (prime)
primorial(3229) + 1 = 689,481,240,122,180,255,681,227,812,346,871,771,457,221,628,238,467,511,261,402,638,443,056,696,165,896,544,725,098,860,107,293,247,422,610,010,824,870,599,655,026,129,367,004,672,337,297,193,288,816,463,520,704,235,722,580,204,218,943,598,425,089,855,869,341,564,771,022,924,163,236,141,415,235,947,085,902,422,536,824,665,765,244,189,167,643,048,218,572,769,125,400,511,177,245,717,452,516,267,205,786,258,497,574,258,715,214,994,129,786,103,824,740,384,634,788,909,041,221,747,073,062,941,769,355,745,272,170,421,584,636,198,911,899,164,272,930,590,704,655,882,680,817,754,473,306,122,122,423,384,160,639,995,940,152,584,830,810,911,265,680,382,263,051,658,031,509,463,010,733,595,465,426,943,956,643,445,876,702,680,730,987,739,513,538,299,069,540,636,616,098,525,527,546,435,002,783,615,353,417,794,625,251,129,892,373,849,727,119,530,335,366,131,575,986,221,685,088,118,143,088,371,896,087,248,659,669,154,564,925,048,225,211,644,681,303,874,490,648,860,319,990,785,185,350,796,853,298,548,942,407,689,617,641,587,755,314,125,485,345,107,782,298,938,892,240,282,038,605,672,241,010,302,874,153,509,795,545,077,305,234,459,038,983,235,361,138,814,897,166,376,363,090,128,647,084,552,385,969,054,439,430,382,421,762,883,708,894,899,853,286,109,068,224,980,793,075,241,538,872,287,253,835,877,394,821,667,363,465,425,187,353,453,157,415,169,810,167,271,517,665,273,484,442,461,468,031,313,956,356,871,467,191,959,110,440,864,194,544,244,079,053,955,897,287,010,339,385,419,923,838,571,256,564,818,350,769,518,898,003,780,557,167,344,272,499,224,580,817,920,441,512,610,104,625,622,872,289,967,615,843,092,782,763,554,732,404,239,287,463,466,833,602,966,629,613,502,579,134,371,295,289,680,374,088,987,611,189,907,873,072,122,808,833,765,972,650,050,982,877,578,244,899,073,193,043,546,490,795,625,023,568,563,926,988,371 (prime)


Elsewhere Other-Accessible

A005234 at the Online Encylopedia of Integer Sequences — “Primorial plus 1 primes: primes p such that 1 + product of primes up to p is prime”.

Period Panes

In The Penguin Dictionary of Curious and Interesting Numbers (1987), David Wells remarks that 142857 is “a number beloved of all recreational mathematicians”. He then explains that it’s “the decimal period of 1/7: 1/7 = 0·142857142857142…” and “the first decimal reciprocal to have maximum period, that is, the length of its period is only one less than the number itself.”

Why does this happen? Because when you’re calculating 1/n, the remainders can only be less than n. In the case of 1/7, you get remainders for all integers less than 7, i.e. there are 6 distinct remainders and 6 = 7-1:

(1*10) / 7 = 1 remainder 3, therefore 1/7 = 0·1...
(3*10) / 7 = 4 remainder 2, therefore 1/7 = 0·14...
(2*10) / 7 = 2 remainder 6, therefore 1/7 = 0·142...
(6*10) / 7 = 8 remainder 4, therefore 1/7 = 0·1428...
(4*10) / 7 = 5 remainder 5, therefore 1/7 = 0·14285...
(5*10) / 7 = 7 remainder 1, therefore 1/7 = 0·142857...
(1*10) / 7 = 1 remainder 3, therefore 1/7 = 0·1428571...
(3*10) / 7 = 4 remainder 2, therefore 1/7 = 0·14285714...
(2*10) / 7 = 2 remainder 6, therefore 1/7 = 0·142857142...

Mathematicians know that reciprocals with maximum period can only be prime reciprocals and with a little effort you can work out whether a prime will yield a maximum period in a particular base. For example, 1/7 has maximum period in bases 3, 5, 10, 12 and 17:

1/21 = 0·010212010212010212... in base 3
1/12 = 0·032412032412032412... in base 5
1/7 =  0·142857142857142857... in base 10
1/7 =  0·186A35186A35186A35... in base 12
1/7 =  0·274E9C274E9C274E9C... in base 17

To see where else 1/7 has maximum period, have a look at this graph:

Period pane for primes 3..251 and bases 2..39


I call it a “period pane”, because it’s a kind of window into the behavior of prime reciprocals. But what is it, exactly? It’s a graph where the x-axis represents primes from 3 upward and the y-axis represents bases from 2 upward. The red squares along the bottom aren’t part of the graph proper, but indicate primes that first occur after a power of two: 5 after 4=2^2; 11 after 8=2^3; 17 after 16=2^4; 37 after 32=2^5; 67 after 64=2^6; and so on.

If a prime reciprocal has maximum period in a particular base, the graph has a solid colored square. Accordingly, the purple square at the bottom left represents 1/7 in base 10. And as though to signal the approval of the goddess of mathematics, the graph contains a lower-case b-for-base, which I’ve marked in green. Here are more period panes in higher resolution (open the images in a new window to see them more clearly):

Period pane for primes 3..587 and bases 2..77


Period pane for primes 3..1303 and bases 2..152


An interesting pattern has begun to appear: note the empty lanes, free of reciprocals with maximum period, that stretch horizontally across the period panes. These lanes are empty because there are no prime reciprocals with maximum period in square bases, that is, bases like 4, 9, 25 and 36, where 4 = 2*2, 9 = 3*3, 25 = 5*5 and 36 = 6*6. I don’t know why square bases don’t have max-period prime reciprocals, but it’s probably obvious to anyone with more mathematical nous than me.

Period pane for primes 3..2939 and bases 2..302


Period pane for primes 3..6553 and bases 2..602


Like the Ulam spiral, other and more mysterious patterns appear in the period panes, hinting at the hidden regularities in the primes.

Sprime Time

All fans of recreational math love palindromic numbers. It’s mandatory, man. 101, 727, 532235, 8810188, 1367755971795577631 — I love ’em! But where can you go after palindromes? Well, you can go to palindromes in a higher dimension. Numbers like 101, 727, 532235 and 8810188 are 1-d palindromes. That is, they’re palindromic in one dimension: backwards and forwards. But numbers like 181818189 and 646464640 aren’t palindromic in one dimension. They’re palindromic in two dimensions:


1 8 1
8 9 8
1 8 1

n=181818189


6 4 6
4 0 4
6 4 6

n=646464640



They’re 2-d palindromes or spiral numbers, that is, numbers that are symmetrical when written as a spiral. You start with the first digit on the top left, then spiral inwards to the center, like this for a 9-digit spiral (9 = 3×3):


And this for a 36-digit spiral (36 = 6×6):


Spiral numbers are easy to construct, because you can reflect and rotate the numbers in one triangular slice of the spiral to find all the others:


You could say that the seed for the spiral number above is 7591310652, because you can write that number in descending lines, left-to-right, as a triangle.

Here are some palindromic numbers with nine digits in base 3 — as you can see, some are both palindromic numbers and spiral numbers. That is, some are palindromic in both one and two dimensions:

1  0  1

0  1  0

1  0  1

n=101010101


1  0  1

0  2  0

1  0  1

n=101010102


1  1  1

1  0  1

1  1  1

n=111111110


1  1  1

1  1  1

1  1  1

n=111111111


2  0  2

0  1  0

2  0  2

n=202020201


2  0  2

0  2  0

2  0  2

n=202020202


2  2  2

2  1  2

2  2  2

n=222222221


2  2  2

2  2  2

2  2  2

n=222222222


But palindromic primes are even better than ordinary palindromes. Here are a few 1-d palindromic primes in base 10:

101
151
73037
7935397
97356765379
1091544334334451901
1367755971795577631
70707270707
39859395893
9212129
7436347
166000661
313
929


And after 1-d palindromic primes, you can go to 2-d palindromic primes. That is, to spiral primes or sprimes — primes that are symmetrical when written as a spiral:

3 6 3
6 7 6
3 6 3

n=363636367 (prime)
seed=367 (see definition above)


9 1 9
1 3 1
9 1 9

n=919191913 (prime)
seed=913


3 7 8 6 3 6 8 7 3
7 9 1 8 9 8 1 9 7
8 1 9 0 9 0 9 1 8
6 8 0 5 5 5 0 8 6
3 9 9 5 7 5 9 9 3
6 8 0 5 5 5 0 8 6
8 1 9 0 9 0 9 1 8
7 9 1 8 9 8 1 9 7
3 7 8 6 3 6 8 7 3

n=378636873786368737863687378636879189819189819189819189819090909090909090555555557 (prime)
seed=378639189909557 (l=15)


And why stop with spiral numbers — and sprimes — in two dimensions? 363636367 is a 2-sprime, being palindromic in two dimensions. But the digits of a number could be written to form a symmetrical cube in three, four, five and more dimensions. So I assume that there are 3-sprimes, 4-sprimes, 5-sprimes and more out there. Watch this space.

Sliv and Let Tri

Fluvius, planus et altus, in quo et agnus ambulet et elephas natet,” wrote Pope Gregory the Great (540-604). “There’s a river, wide and deep, where a lamb may wade and an elephant swim.” He was talking about the Word of God, but you can easily apply his words to mathematics. However, in the river of mathematics, the very shallow and the very deep are often a single step apart.

Here’s a good example. Take the integer 2. How many different ways can it be represented as an sum of separate integers? Easy. First of all it can be represented as itself: 2 = 2. Next, it can be represented as 2 = 1 + 1. And that’s it. There are two partitions of 2, as mathematicians say:

2 = 2 = 1+1 (p=2)


Now try 3, 4, 5, 6:

3 = 3 = 1+2 = 1+1+1 (p=3)
4 = 4 = 1+3 = 2+2 = 1+1+2 = 1+1+1+1 (p=5)
5 = 5 = 1+4 = 2+3 = 1+1+3 = 1+2+2 = 1+1+1+2 = 1+1+1+1+1 (p=7)
6 = 6 = 1+5 = 2+4 = 3+3 = 1+1+4 = 1+2+3 = 2+2+2 = 1+1+1+3 = 1+1+2+2 = 1+1+1+1+2 = 1+1+1+1+1+1 (p=11)


So the partitions of 2, 3, 4, 5, 6 are 2, 3, 5, 7, 11. That’s interesting — the partition-counts are the prime numbers in sequence. So you might conjecture that p(7) = 13 and p(8) = 17. Alas, you’d be wrong. Here are the partitions of n = 1..10:

1 = 1 (p=1)
2 = 2 = 1+1 (p=2)
3 = 3 = 1+2 = 1+1+1 (p=3)
4 = 4 = 1+3 = 2+2 = 1+1+2 = 1+1+1+1 (p=5)
5 = 5 = 1+4 = 2+3 = 1+1+3 = 1+2+2 = 1+1+1+2 = 1+1+1+1+1 (p=7)
6 = 6 = 1+5 = 2+4 = 3+3 = 1+1+4 = 1+2+3 = 2+2+2 = 1+1+1+3 = 1+1+2+2 = 1+1+1+1+2 = 1+1+1+1+1+1 (p=11)
7 = 7 = 1+6 = 2+5 = 3+4 = 1+1+5 = 1+2+4 = 1+3+3 = 2+2+3 = 1+1+1+4 = 1+1+2+3 = 1+2+2+2 = 1+1+1+1+3 = 1+1+1+2+2 = 1+1+1+1+1+2 = 1+1+1+1+1+1+1 (p=15)
8 = 8 = 1+7 = 2+6 = 3+5 = 4+4 = 1+1+6 = 1+2+5 = 1+3+4 = 2+2+4 = 2+3+3 = 1+1+1+5 = 1+1+2+4 = 1+1+3+3 = 1+2+2+3 = 2+2+2+2 = 1+1+1+1+4 = 1+1+1+2+3 = 1+1+2+2+2 = 1+1+1+1+1+3 = 1+1+1+1+2+2 = 1+1+1+1+1+1+2 = 1+1+1+1+1+1+1+1 (p=22)
9 = 9 = 1+8 = 2+7 = 3+6 = 4+5 = 1+1+7 = 1+2+6 = 1+3+5 = 1+4+4 = 2+2+5 = 2+3+4 = 3+3+3 = 1+1+1+6 = 1+1+2+5 = 1+1+3+4 = 1+2+2+4 = 1+2+3+3 = 2+2+2+3 = 1+1+1+1+5 = 1+1+1+2+4 = 1+1+1+3+3 = 1+1+2+2+3 = 1+2+2+2+2 = 1+1+1+1+1+4 = 1+1+1+1+2+3 = 1+1+1+2+2+2 = 1+1+1+1+1+1+3 = 1+1+1+1+1+2+2 = 1+1+1+1+1+1+1+2 = 1+1+1+1+1+1+1+1+1 (p=30)
10 = 10 = 1+9 = 2+8 = 3+7 = 4+6 = 5+5 = 1+1+8 = 1+2+7 = 1+3+6 = 1+4+5 = 2+2+6 = 2+3+5 = 2+4+4 = 3+3+4 = 1+1+1+7 = 1+1+2+6 = 1+1+3+5 = 1+1+4+4 = 1+2+2+5 = 1+2+3+4 = 1+3+3+3 = 2+2+2+4 = 2+2+3+3 = 1+1+1+1+6 = 1+1+1+2+5 = 1+1+1+3+4 = 1+1+2+2+4 = 1+1+2+3+3 = 1+2+2+2+3 = 2+2+2+2+2 = 1+1+1+1+1+5 = 1+1+1+1+2+4 = 1+1+1+1+3+3 = 1+1+1+2+2+3 = 1+1+2+2+2+2 = 1+1+1+1+1+1+4 = 1+1+1+1+1+2+3 = 1+1+1+1+2+2+2 = 1+1+1+1+1+1+1+3 = 1+1+1+1+1+1+2+2 = 1+1+1+1+1+1+1+1+2 = 1+1+1+1+1+1+1+1+1+1 (p=42)


It’s very simple to understand what a partition is, but very difficult to say how many partitions, p(n), a particular number will have. Here’s a partition: 11 = 4 + 3 + 2 + 2. But what is p(11)? Is there a formula for the sequence of p(n)?

1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176, 231, 297, 385, 490, 627, 792, 1002, 1255, 1575, 1958, 2436, 3010, 3718, 4565, 5604, 6842, 8349, 10143, 12310, 14883, 17977, 21637, 26015, 3118 5, 37338, 44583, 53174, 63261... (A000041 at the OEIS)

Yes, there is a formula, but it is very difficult to understand the Partition function that supplies it. So that part of the river of mathematics is very deep. But a step away the river of mathematics is very shallow. Here’s another question: If you multiply the numbers in a partition of n, what’s the largest possible product? Try using the partitions of 5:

4 = 1 * 4
6 = 2 * 3
3 = 1 * 1 * 3
4 = 1 * 2 * 2
2 = 1 * 1 * 1 * 2
1 = 1 * 1 * 1 * 1 * 1

The largest product is 6 = 2 * 3. So the answer is easy for n = 5, but I assumed that as n got bigger, the largest product got more interesting, using a subtler and subtler mix of prime factors. I was wrong. You don’t have to struggle to find a formula for what you might call the maximum multiplicity of the partitions of n:

1 = 1 (n=1)
2 = 2 (n=2)
3 = 3 (n=3)
4 = 2 * 2 (n=4)
6 = 2 * 3 (n=5)
9 = 3 * 3 (n=6)
12 = 2 * 2 * 3 (n=7)
18 = 2 * 3 * 3 (n=8)
27 = 3 * 3 * 3 (n=9)
36 = 2 * 2 * 3 * 3 (n=10)
54 = 2 * 3 * 3 * 3 (n=11)
81 = 3 * 3 * 3 * 3 (n=12)
108 = 2 * 2 * 3 * 3 * 3 (n=13)
162 = 2 * 3 * 3 * 3 * 3 162(n=14)
243 = 3 * 3 * 3 * 3 * 3 (n=15)
324 = 2 * 2 * 3 * 3 * 3 * 3 (n=16)
486 = 2 * 3 * 3 * 3 * 3 * 3 (n=17)
729 = 3 * 3 * 3 * 3 * 3 * 3 (n=18)


It’s easy to see why the greatest prime factor is always 3. If you use 5 or 7 as a factor, the product can always be beaten by splitting the 5 into 2*3 or the 7 into 2*2*3:

15 = 3 * 5 < 18 = 3 * 2*3 (n=8)
14 = 2 * 7 < 24 = 2 * 2*2*3 (n=9)
35 = 5 * 7 < 72 = 2*3 * 2*2*3 (n=12)

And if you’re using 7 → 2*2*3 as factors, you can convert them to 1*3*3, then add the 1 to another factor to make a bigger product still:

14 = 2 * 7 < 24 = 2 * 2*2*3 < 27 = 3 * 3 * 3 (n=9)
35 = 5 * 7 < 72 = 2*3 * 2*2*3 < 81 = 3 * 3 * 3 * 3 (n=12)


Post-Performative Post-Scriptum

The title of this post is, of course, a paronomasia on core Beatles album Live and Let Die (1954). But what does it mean? Well, if you think of the partitions of n as slivers of n, then you sliv n to find its partitions:

9 = 9 = 1+8 = 2+7 = 3+6 = 4+5 = 1+1+7 = 1+2+6 = 1+3+5 = 1+4+4 = 2+2+5 = 2+3+4 = 3+3+3 = 1+1+1+6 = 1+1+2+5 = 1+1+3+4 = 1+2+2+4 = 1+2+3+3 = 2+2+2+3 = 1+1+1+1+5 = 1+1+1+2+4 = 1+1+1+3+3 = 1+1+2+2+3 = 1+2+2+2+2 = 1+1+1+1+1+4 = 1+1+1+1+2+3 = 1+1+1+2+2+2 = 1+1+1+1+1+1+3 = 1+1+1+1+1+2+2 = 1+1+1+1+1+1+1+2 = 1+1+1+1+1+1+1+1+1 (p=30)

And when you find the greatest product among those partitions, you let 3 or “tri” work its multiplicative magic. So you “Sliv and Let Tri”:

8 = 1 * 8
14 = 2 * 7
18 = 3 * 6
20 = 4 * 5
7 = 1 * 1 * 7
12 = 1 * 2 * 6
15 = 1 * 3 * 5
16 = 1 * 4 * 4
20 = 2 * 2 * 5
24 = 2 * 3 * 4
27 = 3 * 3 * 3 ←
6 = 1 * 1 * 1 * 6
10 = 1 * 1 * 2 * 5
12 = 1 * 1 * 3 * 4
16 = 1 * 2 * 2 * 4
12 = 1 * 2 * 3 * 3
24 = 2 * 2 * 2 * 3
5 = 1 * 1 * 1 * 1 * 5
8 = 1 * 1 * 1 * 2 * 4
9 = 1 * 1 * 1 * 3 * 3
12 = 1 * 1 * 2 * 2 * 3
16 = 1 * 2 * 2 * 2 * 2
4 = 1 * 1 * 1 * 1 * 1 * 4
6 = 1 * 1 * 1 * 1 * 2 * 3
8 = 1 * 1 * 1 * 2 * 2 * 2
3 = 1 * 1 * 1 * 1 * 1 * 1 * 3
4 = 1 * 1 * 1 * 1 * 1 * 2 * 2
2 = 1 * 1 * 1 * 1 * 1 * 1 * 1 * 2
1 = 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1

Year and Square

The simplest and in some ways greatest magic square is this:

6 1 8
7 5 3
2 9 4 (Magic total = 15)

All rows and columns sum to 15 and so do both diagonals. Using other sets of numbers, you can create an infinite number of further 3×3 magic squares. Here’s one using only prime numbers and 1:

43 01 67
61 37 13
07 73 31 (Magic=111)

The magic total is 111, which is 3 x 37, just as 15 = 3 x 5. It’s an interesting but untaxing exercise to prove that, for all 3×3 magic squares, the magic total is three times the central number. So you can use only prime numbers in a 3×3 square, but you can’t have a prime number as the magic total (unless you use fractions and so on).

And guess what? 2019 = 3 x 667, the first prime number after 666. So I decided to see if I could find an all-prime magic squares whose magic total was 2019. I found nine of them (and 9 = 3 x 3).

1117 0019 0883
0439 0673 0907
0463 1327 0229 (Magic=2019)

1069 0067 0883
0487 0673 0859
0463 1279 0277 (Magic=2019)

1063 0229 0727
0337 0673 1009
0619 1117 0283 (Magic=2019)

0883 0313 0823
0613 0673 0733
0523 1033 0463 (Magic=2019)

0619 0337 1063
1117 0673 0229
0283 1009 0727 (Magic=2019)

0463 0439 1117
1327 0673 0019
0229 0907 0883 (Magic=2019)

0463 0487 1069
1279 0673 0067
0277 0859 0883 (Magic=2019)

0379 0607 1033
1327 0673 0019
0313 0739 0967 (Magic=2019)

0523 0613 0883
1033 0673 0313
0463 0733 0823 (Magic=2019)

WhirlpUlam

Stanislaw Ulam (pronounced OO-lam) was an American mathematician who was doodling one day in 1963 and created what is now called the Ulam spiral. It’s a spiral of integers on a square grid with the prime squares filled in and the composite squares left empty. At the beginning it looks like this (the blue square is the integer 1, with 2 to the east, 3 to the north-east, 4 to the north, 5 to the north-west, 6 to the west, and so on):

Ulam spiral


And here’s an Ulam spiral with more integers:

Ulam spiral at higher resolution


The primes aren’t scattered at random over the spiral: they often fall into lines that are related to what are called polynomial functions, such as n2 + n + 1. To understand polynomial functions better, let’s look at how the Ulam spiral is made. Here is a text version with the primes underlined:


Here’s an animated version:


Here’s the true spiral again with 1 marked as a blue square:

Ulam spiral centred on 1


What happens when you try other numbers at the centre? Here’s 2 at the centre as a purple square, because it’s prime:

Ulam spiral centred on 2


And 3 at the centre, also purple because it’s also prime:

Ulam spiral centred on 3


And 4 at the centre, blue again because 4 = 2^2:

Ulam spiral centred on 4


And 5 at the centre, prime and purple:

Ulam spiral centred on 5


Each time the central number changes, the spiral shifts fractionally. Here’s an animation of the central number shifting from 1 to 41. If you watch, you’ll see patterns remaining stable, then breaking up as the numbers shift towards the center and disappear (the central number is purple if prime, blue if composite):

Ulam whirlpool, or WhirlpUlam


I think the animation looks like a whirlpool or whirlpUlam (prounced whirlpool-am), as numbers spiral towards the centre and disappear. You can see the whirlpUlam more clearly here:

An animated Ulam Spiral pausing at n=11, 17, 41


WhirlpUlam again


Note that something interesting happens when the central number is 41. The spiral is bisected by a long line of prime squares, like this:

Ulam spiral centred on 41


The line is actually a visual representation of something David Wells wrote about in The Penguin Dictionary of Curious and Interesting Numbers (1986):

Euler discovered the excellent and famous formula x2 + x + 41, which gives prime values for x = 0 to 39.

Here are the primes generated by the formula:

41, 43, 47, 53, 61, 71, 83, 97, 113, 131, 151, 173, 197, 223, 251, 281, 313, 347, 383, 421, 461, 503, 547, 593, 641, 691, 743, 797, 853, 911, 971, 1033, 1097, 1163, 1231, 1301, 1373, 1447, 1523, 1601

You’ll see other lines appear and disappear as the whirlpUlam whirls:

Ulam spiral centred on 17


Primes in line: 17, 19, 23, 29, 37, 47, 59, 73, 89, 107, 127, 149, 173, 199, 227, 257 (n=0..15)


Ulam spiral centred on 59


Primes in line: 59, 67, 83, 107, 139, 179, 227, 283, 347, 419, 499, 587, 683, 787 (n=0..13)


Ulam spiral centred on 163


Primes in line: 163, 167, 179, 199, 227, 263, 307, 359, 419, 487, 563, 647, 739, 839, 947, 1063, 1187, 1319, 1459, 1607 (n=0..19)


Ulam spiral centred on 233


Primes in line: 233, 241, 257, 281, 313, 353, 401, 457, 521, 593, 673, 761, 857 ((n=0..12)


Ulam spiral centred on 653


Primes in line: 653, 661, 677, 701, 733, 773, 821, 877, 941, 1013, 1093, 1181, 1277, 1381, 1493, 1613, 1741, 1877 (n=0..17)


Ulam spiral centred on 409,333


Primes in line: 409,333, 409337, 409349, 409369, 409397, 409433, 409477, 409529, 409589, 409657, 409733, 409817, 409909, 410009, 410117, 410233 (n=0..15)


Some bisect the centre, some don’t, because you could say that the Ulam spiral has six diagonals, two that bisect the centre (top-left-to-bottom-right and bottom-left-to-top-right) and four that don’t. You could also call them spokes:


If you look at the integers in the spokes, you can see that they’re generated by polynomial functions in which c stands for the central number:

North-west spoke: 1, 5, 17, 37, 65, 101, 145, 197, 257, 325, 401, 485, 577, 677, 785, 901, 1025, 1157, 1297, 1445, 1601, 1765, 1937, 2117, 2305, 2501, 2705, 2917... = c + (2n)^2


South-east spoke: 1, 9, 25, 49, 81, 121, 169, 225, 289, 361, 441, 529, 625, 729, 841, 961, 1089, 1225, 1369, 1521, 1681, 1849, 2025, 2209, 2401, 2601, 2809, 3025, 3249, 3481, 3721, 3969, 4225, 4489, 4761, 5041, 5329, 5625... = c+(2n+1)^2-1


NW-SE diagonal: 1, 5, 9, 17, 25, 37, 49, 65, 81, 101, 121, 145, 169, 197, 225, 257, 289, 325, 361, 401, 441, 485, 529, 577, 625, 677, 729, 785, 841, 901, 961, 1025, 1089, 1157, 1225, 1297, 1369, 1445, 1521, 1601, 1681 = c + n^2 + 1 - (n mod 2)


North-east spoke: 1, 3, 13, 31, 57, 91, 133, 183, 241, 307, 381, 463, 553, 651, 757, 871, 993, 1123, 1261, 1407, 1561, 1723, 1893, 2071... = c + (n+1)^2 - n - 1


South-west spoke: 1, 7, 21, 43, 73, 111, 157, 211, 273, 343, 421, 507, 601, 703, 813, 931, 1057, 1191, 1333, 1483, 1641, 1807, 1981, 2163... = c + (2n)^2 + 2n


SW-NE diagonal: 1, 3, 7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273, 307, 343, 381, 421, 463, 507, 553, 601, 651, 703, 757, 813, 871, 931, 993, 1057, 1123, 1191, 1261, 1333, 1407, 1483, 1561, 1641... = c + n^2 + n



Elsewhere other-engageable:

All posts interrogating issues around the Ulam spiral