Explicit formulas for the array in A308896 N. J. Sloane, July 02 2019 Here is the central 21 X 21 portion of the plane, showing the values of a(n) written along the spiral. (The spiral is not shown in this drawing, but it starts at the center, proceeds East, North, West, South, East, North, etc. in a counter-clockwise "square spiral". y: 10 [ 4 1 3 30 31 28 29 26 27 24 25 22 23 20 21 18 19 16 17 2 0] 9 [ 5 2 1 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 0 3] 8 [18 17 16 1 3 6 7 12 13 14 15 8 9 10 11 4 5 2 0 31 30] 7 [19 16 17 2 1 7 6 13 12 15 14 9 8 11 10 5 4 0 3 30 31] 6 [16 19 18 5 4 1 3 14 15 12 13 10 11 8 9 2 0 7 6 29 28] 5 [17 18 19 4 5 2 1 15 14 13 12 11 10 9 8 0 3 6 7 28 29] 4 [22 21 20 11 10 9 8 1 3 6 7 4 5 2 0 15 14 13 12 27 26] 3 [23 20 21 10 11 8 9 2 1 7 6 5 4 0 3 14 15 12 13 26 27] 2 [20 23 22 9 8 11 10 5 4 1 3 2 0 7 6 13 12 15 14 25 24] 1 [21 22 23 8 9 10 11 4 5 2 1 0 3 6 7 12 13 14 15 24 25] 0 [26 25 24 15 14 13 12 7 6 3 *0* 1 2 5 4 11 10 9 8 23 22] -1 [27 24 25 14 15 12 13 6 7 0 2 3 1 4 5 10 11 8 9 22 23] -2 [24 27 26 13 12 15 14 3 0 4 5 6 7 1 2 9 8 11 10 21 20] -3 [25 26 27 12 13 14 15 0 2 5 4 7 6 3 1 8 9 10 11 20 21] -4 [30 29 28 7 6 3 0 8 9 10 11 12 13 14 15 1 2 5 4 19 18] -5 [31 28 29 6 7 0 2 9 8 11 10 13 12 15 14 3 1 4 5 18 19] -6 [28 31 30 3 0 4 5 10 11 8 9 14 15 12 13 6 7 1 2 17 16] -7 [29 30 31 0 2 5 4 11 10 9 8 15 14 13 12 7 6 3 1 16 17] -8 [ 6 3 0 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2] -9 [ 7 0 2 17 16 19 18 21 20 23 22 25 24 27 26 29 28 31 30 3 1] -10 [ 0 4 5 18 19 16 17 22 23 20 21 26 27 24 25 30 31 28 29 6 7] -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 =================================== x =============================== The following formulas specify the entries A[x,y] in the array. Officially these are only conjectural, but there would be no difficulty in giving a proof by induction. Note that the array is divided into 8 triangular sectors, roughly by the lines x=0, y=0, and y = +- x. The actual division lines are the two diagonal lines of 0's and 1's, the horizontal line y=1/2; and the vertical line x=1/2. Apart from the boundaries of the sectors, the structure has four-fold cyclic symmetry. (The boundary lines are sometimes all 0's, sometimes all 1's.) There are essentially just two kinds of sectors. See the attached drawing, which has an enlarged picture of the two sectors. The first type of sector is bounded by the lines y=1/2 and y=x, and looks like this: 0 ... 0 3 ... 0 31 30 ... 0 3 30 31 ... 0 7 6 29 28 ... 0 3 6 7 28 29 ... 0 15 14 13 12 27 26 ... 0 3 14 15 12 13 26 27 ... 0 7 6 13 12 15 14 25 24 ... 0 3 6 7 12 13 14 15 24 25 ... The columns correspond to x = 1,2,3,4,5,... and the rows (reading upwards) to y = 1,2,3,4,5,... The key sequence here is the bottom row. Ignoring the 0, we define this to be L(n), n>=1, thus: n = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ... L(n) = 3, 6, 7, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31, 48, ... This is essentially A004760. We may regard it as a list of the numbers whose binary expansion begins 11, or as defined by the recurrence L(2*n) = 2*L(n), L(2*n+1) = 2*L(n)+1. Then the formula for this sector is: A[x,y] = L(x-1) XOR (y-1), for x >= 4*ceiling(y/4) + 1 where XOR means: write the numbers in binary and add them mod 2. For the beginnings of the rows, that is, the (at most 4) terms A[x,y] with y <= x <= 4*ceiling(y/4) , insert 0 3 6 7 if y==1 mod 4, 0 7 6 for y==2 mod 4, 0 3 for y==3 mod 4, and 0 for y==0 mod 4. The second type of sector is bounded by the lines y=1/2 and y=-x, and looks like this: 1 2 5 4 11 10 9 8 23 22 ... 1 4 5 10 11 8 9 22 23 ... 1 2 9 8 11 10 21 20 ... 1 8 9 10 11 20 21 ... 1 2 5 4 19 18 ... 1 4 5 18 19 ... 1 2 17 16 ... 1 16 17 ... 1 2 ... 1 ... The columns correspond to x = 1,2,3,4,5,... and the rows (reading downwards) to y = -1,-2,-3,-4,-5,... Let s = -y, so s = 1,2,3,... The key sequence now is the top row. Ignoring the 1, we define it to be M(n), n>=1, thus: n = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ... M(n) = 2, 5, 4, 11, 10, 9, 8, 23, 22, 21, 20, 19, 18, 17, 16, 47, 46, ... This is essentially A010078. The simplest definition for our purpose is M(n) = C(n) - L(n), where if 2^r <= n < 2^(r+1), C(n) = 3*2^(r+1) - 1. (So M(n)+L(n) is constant on blocks, with values 5, 11, 23, 47, 95, ...) M(n) satisfies the recurrence M(2*n) = 2*M(n)+1, M(2*n+1) = 2*M(n). The values of M(n) are a re-ordered list of the numbers whose binary expansion begins 10. Then the formula for this sector is: A[x,-s] = M(x) XOR s, for x >= 4*floor(s/4) + 5. For the beginnings of the rows, that is, the (at most 4) terms A[x,-s] with s+1 <= x <= 4*floor(s/4) + 4, insert 1 2 5 4 if s==0 mod 4, 1 4 5 for s==1 mod 4, 1 2 for s==2 mod 4, and 1 for s==3 mod 4. Remark: The i-th row of the first type of sector is the complement of the i-th row of the second type of sector. Because of the cyclic four-fold symmetry, this shows that every row in the array is a permutation of the nonnegative integers, and similarly for the columns. For this problem, the diagonals are not permutations.