login
A317612
For k >= 1, fill a k X k square with the numbers 1 to k^2 by rows left to right and top to bottom; then read the square by a square clockwise spiral beginning at the top left and spiraling inwards.
0
1, 1, 2, 4, 3, 1, 2, 3, 6, 9, 8, 7, 4, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10, 1, 2, 3, 4, 5, 10, 15, 20, 25, 24, 23, 22, 21, 16, 11, 6, 7, 8, 9, 14, 19, 18, 17, 12, 13, 1, 2, 3, 4, 5, 6, 12, 18, 24, 30, 36, 35, 34, 33, 32, 31, 25, 19, 13, 7, 8, 9, 10, 11, 17, 23, 29, 28, 27, 26, 20, 14, 15, 16, 22, 21, 1, 2, 3, 4, 5, 6, 7, 14, 21, 28, 35, 42, 49, 48, 47, 46, 45, 44, 43
OFFSET
1,3
COMMENTS
Inspired by A317186.
The final term in the k X k spiral is A031878(k+1).
EXAMPLE
1 => 1;
.
1---2
|
3---4 => 1, 2, 4, 3;
.
1---2---3
|
4---5 6
| |
7---8---9 => 1, 2, 3, 6, 9, 8, 7, 4, 5;
.
1---2---3---4
|
5---6---7 8
| | |
9 10--11 12
| |
13--14--15--16
.
=> 1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10;
.
1---2---3---4---5
|
6---7---8---9 10
| | |
11 12--13 14 15
| | | |
16 17--18--19 20
| |
21--22--23--24--25
.
=> 1, 2, 3, 4, 5, 10, 15, 20, 25, 24, 23, 22, 21, 16, 11, 6, 7, 8, 9, 14, 19, 18, 17, 12, 13;
.
1---2---3---4---5---6
|
7---8---9--10--11 12
| | |
13 14--15--16 17 18
| | | | |
19 20 21--22 23 24
| | | |
25 26--27--28--29 30
| |
31--32--33--34--35--36
.
=> 1, 2, 3, 4, 5, 6, 12, 18, 24, 30, 36, 35, 34, 33, 32, 31, 25, 19, 13, 7, 8, 9, 10, 11, 17, 23, 29, 28, 27, 26, 20, 14, 15, 16, 22, 21;
MATHEMATICA
(* To form an n X n square table which begins left to right, then top to bottom *) a[i_, j_, n_] := j + n*(i - 1); f[n_] := Table[ a[i, j, n], {i, n}, {j, n}]
CROSSREFS
Sequence in context: A227862 A229802 A106581 * A070402 A125941 A347270
KEYWORD
easy,nonn
AUTHOR
George E. Laham II and Robert G. Wilson v, Aug 01 2018
STATUS
approved