OFFSET
1,2
COMMENTS
To begin, 1 is placed at square (x,y) = (0,0); this then becomes square s = 1. Integers are added sequentially to the open squares of the neighborhood around square s. The neighborhood of a square is defined as: east (x+1,y), south (x,y-1), west (x-1,y), and north (x,y+1). The order in which numbers may be added to a neighborhood is always east, south, west, then north.
Numbers are added to open squares in the neighborhood of square s following the given order. The next number added to the grid is always the smallest positive integer not yet present on the grid. If a filled square is encountered within the current square's neighborhood, the process moves to the next direction in the order. Once the process has cycled through all directions of the neighborhood of a given square s, the process is repeated at square s+1.
The filled grid is then read as a clockwise square spiral, oriented east starting at (0,0). a(n) is the n-th term along the square spiral.
Since each positive integer is added to the grid once, reading the grid as a spiral gives a permutation of the positive integers. Similar permutations can be created by expanding the neighborhood of s.
LINKS
John Tyler Rascoe, Table of n, a(n) for n = 1..10000
John Tyler Rascoe, Python program
EXAMPLE
The spiral begins:
.
41
.
40 25 32
.
39--24--13--18--30
. |
38 23 12---5-- 8--16 28
. | | |
37 22 11 4 1---2 6 14 26
. | | | |
36 21 10---3---7 15 27
. | |
35--20---9--17--29
.
34 19 31
.
33
PROG
(Python) # see linked program
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
John Tyler Rascoe, Mar 04 2023
STATUS
approved