A353590 Lexicographically earliest permutation of the nonnegative integers filling an infinite square array by falling antidiagonals so that the elements on any 2 X 2 square sum to a square.
0, 1, 2, 3, 6, 4, 5, 15, 13, 7, 8, 26, 30, 12, 9, 10, 25, 29, 45, 21, 11, 14, 38, 20, 17, 22, 23, 16, 18, 19, 61, 34, 37, 55, 31, 24, 27, 49, 51, 54, 33, 82, 35, 50, 28, 32, 75, 77, 59, 48, 44, 53, 80, 42, 36, 39, 62, 88, 69, 64, 71, 46, 57, 84, 63, 40, 41, 92, 99, 90, 97, 73, 95
Offset: 0
Keywords
Examples
The square array starts: 0 1 3 5 8 10 14 18 27 32 ... 2 6 15 26 25 38 19 49 75 ... 4 13 30 29 20 61 51 77 ... 7 12 45 17 34 54 59 ... 9 21 22 37 33 48 ... 11 23 55 82 44 ... 16 31 35 53 ... 24 50 80 ... 28 42 ... 36 ... ... a(4) is in the second row and column. It must sum up with a(0) = 0, a(1) = 1 and a(2) = 2 to a square, the smallest possible solution is a(4) = 6. Similarly, a(7) which is on the second row, third column, must sum up with a(1) = 1 (above to the left), a(3) = 3 (above) and a(4) = 6 (to the left) to a square; the smallest solution is a(7) = 15.
Crossrefs
Programs
-
PARI
A353590_upto(N, M=Map(), r,c, U=[-1])={vector(N, i, if(r && c, my(s=mapget(M,[r-1,c-1])+mapget(M,[r-1,c])+mapget(M,[r,c-1]), m=sqrtint(s)+1); while(setsearch(U, N=m^2-s)||N<=U[1], m+=1); U=setunion(U, [N]), N=U[1]+=1); mapput(M,[r,c], N); if(c, c--;r++, r=!c=r+1); while(#U>2 && U[2]==U[1]+1, U=U[^1]); N)}
Comments