%I #57 May 13 2022 18:14:03
%S 1,8,24,48,80,120,168,224,288,360,440,528,624,728,840,960,1088,1224,
%T 1368,1520,1680,1848,2024,2208,2400,2600,2808,3024,3248,3480,3720,
%U 3968,4224,4488,4760,5040,5328,5624,5928,6240,6560,6888,7224,7568,7920,8280,8648,9024,9408,9800,10200,10608
%N Squares visited by a chess king moving on a square-spiral numbered board where the king moves to the adjacent unvisited square containing the spiral number with the most divisors. In case of a tie it chooses the square with the highest spiral number.
%C This sequence gives the numbers of the squares visited by a chess king moving on a square-spiral numbered board where the king starts on the 1 numbered square and at each step moves to an adjacent unvisited square, out of the eight adjacent neighboring squares, which contains the number with the most divisors. If two or more adjacent squares exist with the same highest number of divisors then the square with the highest spiral number is chosen. Given both of these rules tend to force the king to squares with larger numbers, and thus move away from the central 1 starting square, it is remarkable that the king is eventually trapped. Note that if the king simply moves to the highest available number the sequence will be infinite as the king will step along the southeast diagonal from square 1 forever.
%C The sequence is finite. After 1113 steps the square with number 855481 is visited, after which all adjacent neighboring squares have been visited.
%C Due to the king's preference for squares with the most divisors it will avoid prime numbers unless no other choice exists. Of the 1113 visited squares only once does it visit a square with a prime number, at a(308) = 108223. This is due to a(307) = 106913 having square 108223 as its sole neighboring unvisited square. This is the only time in the sequence where only one unvisited adjacent neighbor is available.
%C As even numbers >= 6 will always contain 4 or more divisors the king will tend to visit more even numbers than odd numbers; in the 1113 visited squares 929 contain an even number while only 184 contain an odd number.
%C As the even numbers are diagonally adjacent in the square spiral the king's path will be dominated by diagonal steps, often taking many diagonal steps in succession - see the attached link image. In fact after the first downward step to 8 the next 110 steps are along the southeast diagonal, stepping to successively larger even numbers. This sequence is finally broken on the 112th step when the square with number 50624, with 28 divisors, is the next square in the southeast direction. However the square with number 50622, with 32 divisors, is in the southwest direction so is the next square chosen. It is not until the 166th step, to the square with number 108230, that the path takes a step to a lower number than the one it is currently on.
%C The largest visited square is a(1050) = 942676. The visited square with the maximum number of divisors is a(680) = 388080, which has 180 divisors. The lowest unvisited square is 2.
%H Scott R. Shannon, <a href="/A333714/b333714.txt">Table of n, a(n) for n = 1..1114</a>
%H Scott R. Shannon, <a href="/A333714/a333714.png">Image showing the 1113 steps of the king's path</a>. A green dot marks the starting 1 square and a red dot the final square with number 855481. The red dot is surrounded by eight blue dots to show the occupied neighboring squares. A yellow dots marks the smallest unvisited square with number 2.
%e The board is numbered with the square spiral:
%e .
%e 17--16--15--14--13 .
%e | | .
%e 18 5---4---3 12 29
%e | | | | |
%e 19 6 1---2 11 28
%e | | | |
%e 20 7---8---9--10 27
%e | |
%e 21--22--23--24--25--26
%e .
%e a(1) = 1, the starting square for the king.
%e a(2) = 8. The eight unvisited squares around a(1) the king can move to are numbered 2,3,4,5,6,7,8,9. Of these 6 and 8 both have the maximum four divisors, and of those 8 is the largest.
%e a(3) = 24. The seven unvisited squares around a(2) = 8 the king can move to are numbered 9,2,6,7,22,23,24. Of these 24 has eight divisors, the largest number.
%e a(113) = 50622. The seven unvisited squares around a(112) = 49728 the king can move to are numbered 50622, 49727, 50623, 48841, 50624, 49729, 48842. Of these 50622 has thirty-two divisors, the largest number. This is the step that breaks the sequence of 110 steps to the southeast direction starting from a(2) = 8.
%e a(308) = 108223. This is the first and only time a prime number is visited; a(307) = 106913 has square 108223 as the sole unvisited adjacent neighbor.
%e a(1114) = 855481. The two unvisited squares around a(1113) = 859184 the king can move to are numbered 862894 and 855481. Of these 855481 has eight divisors, the largest number. However square 855481 is surrounded by the eight squares with numbers 859183, 855480, 851785, 859184, 851786, 859185, 855482, 851787 all of which have been previously visited, so the king is trapped.
%Y Cf. A333713 (choose lowest spiral number in case of tie), A335816, A316667, A330008, A329520, A326922, A328928, A328929, A033996.
%K nonn,walk,fini,full
%O 1,2
%A _Scott R. Shannon_, Jul 02 2020