Spiral Artefact

What’s the next number in this sequence of integers?


5, 14, 19, 23, 28, 32, 37, 41, 46, 50, 55... (A227793 at the OEIS)

It shouldn’t be hard to work out that it’s 64 — the sum-of-digits of n is divisible by 5, i.e., digsum(n) mod 5 = 0. Now try summing the numbers in that sequence:


5 + 14 = 19
19 + 19 = 38
38 + 23 = 61
61 + 28 = 89
89 + 32 = 121
121 + 37 = 158
158 + 41 = 199
199 + 46 = 245
[...]

Here are the cumulative sums as another sequence:


5, 19, 38, 61, 89, 121, 158, 199, 245, 295, 350, 414, 483, 556, 634, 716, 803, 894, 990, 1094, 1203, 1316, 1434, 1556, 1683, 1814, 1950, 2090, 2235, 2389, 2548, 2711, 2879, 3051, 3228, 3409, 3595, 3785, 3980, 4183, 4391, 4603, 4820, 5041, 5267, 5497, 5732, 5976, 6225...

And there’s that cumulative-sum sequence represented as a spiral:

Spiral for cumulative sum of n where digsum(n) mod 5 = 0


You can see how the spiral is created by following 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E… from the center:


ZYXWVU
GFEDCT
H432BS
I501AR
J6789Q
KLMNOP

What about other values for the cumulative sums of digsum(n) mod m = 0? Here’s m = 2,3,4,5,6,7:

Spiral for cumulative sum of n where digsum(n) mod 2 = 0
s1 = 2, 4, 6, 8, 11, 13, 15, 17, 19, 20, 22…
s2 = 2, 6, 12, 20, 31, 44, 59, 76, 95, 115… (cumulative sum of s1)


sum of digsum(n) mod 3 = 0
s1 = 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33…
s2 = 3, 9, 18, 30, 45, 63, 84, 108, 135, 165…


sum of digsum(n) mod 4 = 0
s1 = 4, 8, 13, 17, 22, 26, 31, 35, 39, 40, 44…
s2 = 4, 12, 25, 42, 64, 90, 121, 156, 195, 235…


sum of digsum(n) mod 5 = 0
s1 = 5, 14, 19, 23, 28, 32, 37, 41, 46, 50, 55…
s2 = 5, 19, 38, 61, 89, 121, 158, 199, 245, 295…


sum of digsum(n) mod 6 = 0
s1 = 6, 15, 24, 33, 39, 42, 48, 51, 57, 60, 66…
s2 = 6, 21, 45, 78, 117, 159, 207, 258, 315, 375…


sum of digsum(n) mod 7 = 0
s1 = 7, 16, 25, 34, 43, 52, 59, 61, 68, 70, 77…
s2 = 7, 23, 48, 82, 125, 177, 236, 297, 365, 435…


The spiral for m = 2 is strange, but the spirals are similar after that. Until m = 8, when something strange happens again:

sum of digsum(n) mod 8 = 0
s1 = 8, 17, 26, 35, 44, 53, 62, 71, 79, 80, 88…
s2 = 8, 25, 51, 86, 130, 183, 245, 316, 395, 475…


Then the spirals return to normal for m = 9, 10:

sum of digsum(n) mod 9 = 0
s1 = 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99…
s2 = 9, 27, 54, 90, 135, 189, 252, 324, 405, 495…


sum of digsum(n) mod 10 = 0
s1 = 19, 28, 37, 46, 55, 64, 73, 82, 91, 109, 118…
s2 = 19, 47, 84, 130, 185, 249, 322, 404, 495, 604…


Here’s an animated gif of m = 8 at higher and higher resolution:

sum of digsum(n) mod 8 = 0 (animated gif)


You might think this strange behavior is dependant on the base in which the dig-sum is calculated. It isn’t. Here’s an animated gif for other bases in which the mod-8 spiral behaves strangely:

sum of digsum(n) mod 8 = 0 in base b = 5, 6, 7, 9, 11, 12, 13 (animated gif)


But the mod-8 spiral stops behaving strangely when the spiral is like this, as a diamond:


   W
  XIV
 YJ8HU
ZK927GT
LA3016FS
 MB45ER
  NCDQ
   OP

Now the mod-8 spiral looks like this:

sum of digsum(n) mod 8 = 0 (diamond spiral)


But the mod-4 and mod-9 spirals look like this:

sum of digsum(n) mod 4 = 0 (diamond spiral)


sum of digsum(n) mod 9 = 0 (diamond spiral)


You can also construct the spirals as a triangle, like this:


     U
    VCT
   WD2CS
  XE301AR
 YF456789Q
ZGHIJKLMNOP

Here’s the beginning of the mod-5 triangular spiral:

sum of digsum(n) mod 5 = 0 (triangular spiral) (open in new window for full size)


And the beginning of the mod-8 triangular spiral:

sum of digsum(n) mod 8 = 0 (triangular spiral) (open in new window for full size)


The mod-8 spiral is behaving strangely again. So the strangeness is partly an artefact of the way the spirals are constructed.


Post-Performative Post-Scriptum

“Spiral Artefact”, the title of this incendiary intervention, is of course a tip-of-the-hat to core Black-Sabbath track “Spiral Architect”, off core Black-Sabbath album Sabbath Bloody Sabbath, issued in core Black-Sabbath success-period of 1973.

Rollercoaster Rules

n += digsum(n). It’s one of my favorite integer sequences — a rollercoaster to infinity. It works like this: you take a number, sum its digits, add the sum to the original number, and repeat:


1 → 2 → 4 → 8 → 16 → 23 → 28 → 38 → 49 → 62 → 70 → 77 → 91 → 101 → 103 → 107 → 115 → 122 → 127 → 137 → 148 → 161 → 169 → 185 → 199 → 218 → 229 → 242 → 250 → 257 → 271 → 281 → 292 → 305 → 313 → 320 → 325 → 335 → 346 → 359 → 376 → 392 → 406 → 416 → 427 → 440 → 448 → 464 → 478 → 497 → 517 → 530 → 538 → 554 → 568 → 587 → 607 → 620 → 628 → 644 → 658 → 677 → 697 → 719 → 736 → 752 → 766 → 785 → 805 → 818 → 835 → 851 → 865 → 884 → 904 → 917 → 934 → 950 → 964 → 983 → 1003 → 1007 → 1015 → 1022 → 1027 → 1037 → 1048 → 1061 → 1069 → 1085 → 1099 → 1118 → 1129 → 1142 → 1150 → 1157 → 1171 → 1181 → 1192 → 1205 → ...

I call it a rollercoaster to infinity because the digit-sum constantly rises and falls as n gets bigger and bigger. The most dramatic falls are when n gets one digit longer (except on the first occasion):


... → 8 (digit-sum=8) → 16 (digit-sum=7) → ...
... → 91 (ds=10) → 101 (ds=2) → ...
... → 983 (ds=20) → 1003 (ds=4) → ...
... → 9968 (ds=32) → 10000 (ds=1) → ...
... → 99973 (ds=37) → 100010 (ds=2) → ...
... → 999959 (ds=50) → 1000009 (ds=10) → ...
... → 9999953 (ds=53) → 10000006 (ds=7) → ...
... → 99999976 (ds=67) → 100000043 (ds=8) → ...
... → 999999980 (ds=71) → 1000000051 (ds=7) → ...
... → 9999999962 (ds=80) → 10000000042 (ds=7) → ...
... → 99999999968 (ds=95) → 100000000063 (ds=10) → ...
... → 999999999992 (ds=101) → 1000000000093 (ds=13) → ...

Look at 9968 → 10000, when the digit-sum goes from 32 to 1. That’s only the second time that digsum(n) = 1 in the sequence. Does it happen again? I don’t know.

And here’s something else I don’t know. Suppose you introduce a rule for the rollercoaster of n += digsum(n). You buy a ticket with a number on it: 1, 2, 3, 4, 5… Then you get on the rollercoaster powered by with that number. Now here’s the rule: Your ride on the rollercoaster ends when n += digsum(n) yields a rep-digit, i.e., a number whose digits are all the same. Here are the first few rides on the rollercoaster:


1 → 2 → 4 → 8 → 16 → 23 → 28 → 38 → 49 → 62 → 70 → 77
2 → 4 → 8 → 16 → 23 → 28 → 38 → 49 → 62 → 70 → 77
3 → 6 → 12 → 15 → 21 → 24 → 30 → 33
4 → 8 → 16 → 23 → 28 → 38 → 49 → 62 → 70 → 77
5 → 10 → 11
6 → 12 → 15 → 21 → 24 → 30 → 33
7 → 14 → 19 → 29 → 40 → 44
8 → 16 → 23 → 28 → 38 → 49 → 62 → 70 → 77
9 → 18 → 27 → 36 → 45 → 54 → 63 → 72 → 81 → 90 → 99
10 → 11
11 → 13 → 17 → 25 → 32 → 37 → 47 → 58 → 71 → 79 → 95 → 109 → 119 → 130 → 134 → 142 → 149 → 163 → 173 → 184 → 197 → 214 → 221 → 226 → 236 → 247 → 260 → 268 → 284 → 298 → 317 → 328 → 341 → 349 → 365 → 379 → 398 → 418 → 431 → 439 → 455 → 469 → 488 → 508 → 521 → 529 → 545 → 559 → 578 → 598 → 620 → 628 → 644 → 658 → 677 → 697 → 719 → 736 → 752 → 766 → 785 → 805 → 818 → 835 → 851 → 865 → 884 → 904 → 917 → 934 → 950 → 964 → 983 → 1003 → 1007 → 1015 → 1022 → 1027 → 1037 → 1048 → 1061 → 1069 → 1085 → 1099 → 1118 → 1129 → 1142 → 1150 → 1157 → 1171 → 1181 → 1192 → 1205 → 1213 → 1220 → 1225 → 1235 → 1246 → 1259 → 1276 → 1292 → 1306 → 1316 → 1327 → 1340 → 1348 → 1364 → 1378 → 1397 → 1417 → 1430 → 1438 → 1454 → 1468 → 1487 → 1507 → 1520 → 1528 → 1544 → 1558 → 1577 → 1597 → 1619 → 1636 → 1652 → 1666 → 1685 → 1705 → 1718 → 1735 → 1751 → 1765 → 1784 → 1804 → 1817 → 1834 → 1850 → 1864 → 1883 → 1903 → 1916 → 1933 → 1949 → 1972 → 1991 → 2011 → 2015 → 2023 → 2030 → 2035 → 2045 → 2056 → 2069 → 2086 → 2102 → 2107 → 2117 → 2128 → 2141 → 2149 → 2165 → 2179 → 2198 → 2218 → 2231 → 2239 → 2255 → 2269 → 2288 → 2308 → 2321 → 2329 → 2345 → 2359 → 2378 → 2398 → 2420 → 2428 → 2444 → 2458 → 2477 → 2497 → 2519 → 2536 → 2552 → 2566 → 2585 → 2605 → 2618 → 2635 → 2651 → 2665 → 2684 → 2704 → 2717 → 2734 → 2750 → 2764 → 2783 → 2803 → 2816 → 2833 → 2849 → 2872 → 2891 → 2911 → 2924 → 2941 → 2957 → 2980 → 2999 → 3028 → 3041 → 3049 → 3065 → 3079 → 3098 → 3118 → 3131 → 3139 → 3155 → 3169 → 3188 → 3208 → 3221 → 3229 → 3245 → 3259 → 3278 → 3298 → 3320 → 3328 → 3344 → 3358 → 3377 → 3397 → 3419 → 3436 → 3452 → 3466 → 3485 → 3505 → 3518 → 3535 → 3551 → 3565 → 3584 → 3604 → 3617 → 3634 → 3650 → 3664 → 3683 → 3703 → 3716 → 3733 → 3749 → 3772 → 3791 → 3811 → 3824 → 3841 → 3857 → 3880 → 3899 → 3928 → 3950 → 3967 → 3992 → 4015 → 4025 → 4036 → 4049 → 4066 → 4082 → 4096 → 4115 → 4126 → 4139 → 4156 → 4172 → 4186 → 4205 → 4216 → 4229 → 4246 → 4262 → 4276 → 4295 → 4315 → 4328 → 4345 → 4361 → 4375 → 4394 → 4414 → 4427 → 4444

The 11-ticket is much better value than the tickets for 1..10. Bigger numbers behave like this:


1252 → 4444
1253 → 4444
1254 → 888888
1255 → 4444
1256 → 4444
1257 → 888888
1258 → 4444
1259 → 4444
1260 → 9999
1261 → 4444
1262 → 4444
1263 → 888888
1264 → 4444
1265 → 4444
1266 → 888888
1267 → 4444
1268 → 4444
1269 → 9999
1270 → 4444
1271 → 4444
1272 → 888888
1273 → 4444
1274 → 4444

Then all at once, a number-ticket turns golden and the rollercoaster-ride doesn’t end. So far, at least. I’ve tried, but I haven’t been able to find a rep-digit for 3515 and 3529 = 3515+digsum(3515) and so on:


3509 → 4444
3510 → 9999
3511 → 4444
3512 → 4444
3513 → 888888
3514 → 4444
3515 → ?
3516 → 888888
3517 → 4444
3518 → 4444
3519 → 9999
3520 → 4444
3521 → 4444
3522 → 888888
3523 → 4444
3524 → 4444
3525 → 888888
3526 → 4444
3527 → 4444
3528 → 9999
3529 → ?
3530 → 4444
3531 → 888888
3532 → 4444

Does 3515 ever yield a rep-digit for n += digsum(n)? It’s hard to believe it doesn’t, but I’ve no idea how to prove that it does. Except by simply riding the rollercoaster. And if the ride with the 3515-ticket never reaches a rep-digit, the rollercoaster will never let you know. How could it?

But here’s an example in base 23 of how a ticket for n+1 can give you a dramatically longer ride than a ticket for n and n+2:


MI → EEE (524 → 7742)
MJ → EEE (525 → 7742)
MK → 444 (526 → 2212)
ML → 444 (527 → 2212)
MM → MMMMMM (528 → 148035888)
100 → 444 (529 → 2212)
101 → 444 (530 → 2212)
102 → EEE (531 → 7742)
103 → 444 (532 → 2212)
104 → 444 (533 → 2212)
105 → EEE (534 → 7742)
106 → EEE (535 → 7742)
107 → 444 (536 → 2212)
108 → EEE (537 → 7742)
109 → 444 (538 → 2212)
10A → MMMMMM (539 → 148035888)
10B → EEE (540 → 7742)
10C → EEE (541 → 7742)
10D → EEE (542 → 7742)
10E → EEE (543 → 7742)
10F → 444 (544 → 2212)
10G → EEE (545 → 7742)
10H → EEE (546 → 7742)
10I → EEE (547 → 7742)
10J → 444 (548 → 2212)
10K → 444 (549 → 2212)
10L → MMMMMM (550 → 148035888)
10M → EEE (551 → 7742)
110 → EEE (552 → 7742)