In maths, one thing leads to another. I wondered whether, in a spiral of integers, any number was equal to the digit-sum of the numbers on the route traced by moving to the origin first horizontally, then vertically. To illustrate the procedure, here is a 9×9 integer spiral containing 81 numbers:
| 65 | 64 | 63 | 62 | 61 | 60 | 59 | 58 | 57 | | 66 | 37 | 36 | 35 | 34 | 33 | 32 | 31 | 56 | | 67 | 38 | 17 | 16 | 15 | 14 | 13 | 30 | 55 | | 68 | 39 | 18 | 05 | 04 | 03 | 12 | 29 | 54 | | 69 | 40 | 19 | 06 | 01 | 02 | 11 | 28 | 53 | | 70 | 41 | 20 | 07 | 08 | 09 | 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 |
Take the number 21, which is three places across and up from the bottom left corner of the spiral. The route to the origin contains the numbers 21, 22, 23, 8 and 1, because first you move right two places, then up two places. And 21 is what I call a route number, because 21 = 3 + 4 + 5 + 8 + 1 = digitsum(21) + digitsum(22) + digitsum(23) + digitsum(8) + digitsum(1). Beside the trivial case of 1, there are two more route numbers in the spiral:
58 = 13 + 14 + 6 + 7 + 7 + 6 + 4 + 1 = digitsum(58) + digitsum(59) + digitsum(60) + digitsum(61) + digitsum(34) + digitsum(15) + digitsum(4) + digitsum(1).
74 = 11 + 12 + 13 + 14 + 10 + 5 + 8 + 1 = digitsum(74) + digitsum(75) + digitsum(76) + digitsum(77) + digitsum(46) + digitsum(23) + digitsum(8) + digitsum(1).
Then I wondered about other possible routes to the origin. Think of the origin as one corner of a rectangle and the number being tested as the diagonal corner. Suppose that you always move away from the starting corner, that is, you always move up or right (or up and left, and so on, depending on where the corners lie). In a x by y rectangle, how many routes are there between the diagonal corners under those conditions?
It’s an interesting question, but first I’ve looked at the simpler case of an n by n square. You can encode each route as a binary number, with 0 representing a vertical move and 1 representing a horizontal move. The problem then becomes equivalent to finding the number of distinct ways you can arrange equal numbers of 1s and 0s. If you use this method, you’ll discover that there are two routes across the 2×2 square, corresponding to the binary numbers 01 and 10:
Across the 3×3 square, there are six routes, corresponding to the binary numbers 0011, 0101, 0110, 1001, 1010 and 1100:
Across the 4×4 square, there are twenty routes:
Across the 5×5 square, there are 70 routes:
Across the 6×6 and 7×7 squares, there are 252 and 924 routes:
After that, the routes quickly increase in number. This is the list for n = 1 to 14:
1, 2, 6, 20, 70, 252, 924, 3432, 12870, 48620, 184756, 705432, 2704156, 10400600… (see A000984 at the Online Encyclopedia of Integer Sequences)
After that you can vary the conditions. What if you can move not just vertically and horizontally, but diagonally, i.e. vertically and horizontally at the same time? Now you can encode the route with a ternary number, or number in base 3, with 0 representing a vertical move, 1 a horizontal move and 2 a diagonal move. As before, there is one route across a 1×1 square, but there are three across a 2×2, corresponding to the ternary numbers 01, 2 and 10:
There are 13 routes across a 3×3 square, corresponding to the ternary numbers 0011, 201, 021, 22, 0101, 210, 1001, 120, 012, 102, 0110, 1010, 1100:
And what about cubes, hypercubes and higher?