0, 1, 5, 13, 25, 18, 32, 50, 41, 61, 85, 72, 98, 85, 61, 74, 100, 89, 65, 80, 58, 73, 97, 90, 116, 106, 117, 149, 130, 113, 145, 181, 162, 128, 145, 113, 130, 164, 149, 117, 136, 106, 125, 97, 73, 90, 68, 50, 36, 50, 37, 53, 73, 58, 80, 106, 89, 117, 100, 74, 52, 34, 20, 10, 17, 9, 17, 10, 4, 5
Offset: 1
a(3) = 5. The second square has coordinates (0,1) and the sum of the first two numbers is 1 + 2 = 3, which is prime. Therefore, to move as far away from the origin as possible, a step to (1,2) is taken, which has a square distance of 5 units from the origin. Note that a step to (-1,2) could have also been taken and would lead to the same walk by symmetry.
a(6) = 18 as a(5) is at coordinates (3,4) and the sum of the last two square numbers is 4 + 5 = 9, which is composite. Therefore, to step to a square as close as possible to the origin, a step to (3,3) is taken, which has a square distance of 18 units from the origin.
a(9) = 41 as a(8) is at coordinates (5,5) and the sum of the last two square numbers is 7 + 8 = 15, which is composite. Two squares as close as possible to the origin are available, (4,5) and (5,4), both of which have a square distance from the origin of 41 units. Since (4,5) has a square distance of 32 units from the square numbered 2, and (5,4) has a square distance of 34 units from 2, the former is chosen.
Comments