cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A268833 Square array A(n, k) = A101080(k, A003188(n+A006068(k))), read by descending antidiagonals, where A003188 is the binary Gray code, A006068 is its inverse, and A101080(x,y) gives the Hamming distance between binary expansions of x and y.

This page as a plain text file.
%I A268833 #40 Mar 11 2024 18:05:44
%S A268833 0,0,1,0,1,2,0,1,2,1,0,1,2,3,2,0,1,2,3,2,3,0,1,2,1,2,1,2,0,1,2,3,2,3,
%T A268833 2,1,0,1,2,1,2,3,4,3,2,0,1,2,1,2,3,4,3,2,3,0,1,2,3,2,3,4,3,2,3,4,0,1,
%U A268833 2,3,2,3,4,3,2,1,4,3,0,1,2,1,2,1,2,3,2,3,2,3,2,0,1,2,1,2,3,2,1,2,3,2,3,2,3,0,1,2,3,2,3,4,3,2,3,4,1,2,1,2
%N A268833 Square array A(n, k) = A101080(k, A003188(n+A006068(k))), read by descending antidiagonals, where A003188 is the binary Gray code, A006068 is its inverse, and A101080(x,y) gives the Hamming distance between binary expansions of x and y.
%C A268833 The entry at row n, column k, gives the Hamming distance between binary expansions of k and A003188(n+A006068(k)). When Gray code is viewed as a traversal of vertices of an infinite dimensional hypercube by bit-flipping (see the illustration "Visualized as a traversal of vertices of a tesseract" in the Wikipedia's "Gray code" article) the argument k is the "address" (the binary code given inside each vertex) of the starting vertex, and argument n tells how many edges forward along the Gray code path we should hop from it (to the direction that leads away from the vertex with code 0000...). A(n, k) gives then the Hamming distance between the starting and the ending vertex. For how this works with case n=3, see comments in A268676. - _Antti Karttunen_, Mar 11 2024
%H A268833 Antti Karttunen, <a href="/A268833/b268833.txt">Table of n, a(n) for n = 0..32895; the first 256 antidiagonals of array</a>
%H A268833 Wikipedia, <a href="https://en.wikipedia.org/wiki/Gray_code">Gray code</a>.
%F A268833 A(row,col) = A101080(col, A268820(row, row+col)).
%F A268833 A(n, k) = A101080(k, A003188(n+A006068(k))). - _Antti Karttunen_, Mar 11 2024
%e A268833 The top left [0 .. 24] X [0 .. 24] section of the array:
%e A268833 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
%e A268833 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
%e A268833 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
%e A268833 1, 3, 3, 1, 3, 1, 1, 3, 3, 1, 1, 3, 1, 3, 3, 1, 3, 1, 1, 3, 1, 3, 3, 1, 1
%e A268833 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
%e A268833 3, 1, 3, 3, 3, 3, 3, 1, 3, 3, 3, 1, 3, 1, 3, 3, 3, 3, 3, 1, 3, 1, 3, 3, 3
%e A268833 2, 2, 4, 4, 4, 4, 2, 2, 4, 4, 2, 2, 2, 2, 4, 4, 4, 4, 2, 2, 2, 2, 4, 4, 2
%e A268833 1, 3, 3, 3, 3, 3, 1, 3, 3, 3, 1, 3, 1, 3, 3, 3, 3, 3, 1, 3, 1, 3, 3, 3, 1
%e A268833 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
%e A268833 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 1, 3, 3
%e A268833 4, 4, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 4, 4, 4, 4, 4, 4, 2, 2, 4
%e A268833 3, 3, 3, 1, 5, 3, 3, 5, 5, 3, 3, 5, 3, 3, 3, 1, 5, 3, 3, 5, 3, 3, 3, 1, 3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4, 4, 4, 4, 4, 2
%t A268833 A101080[n_, k_]:= DigitCount[BitXor[n, k], 2, 1];A003188[n_]:=BitXor[n, Floor[n/2]]; A006068[n_]:=If[n<2, n, Block[{m=A006068[Floor[n/2]]}, 2m + Mod[Mod[n,2] + Mod[m, 2], 2]]]; a[r_, 0]:= 0; a[0, c_]:=c; a[r_, c_]:= A003188[1 + A006068[a[r - 1, c - 1]]]; A[r_, c_]:=A101080[c, a[r, r + c]]; Table[A[c, r - c], {r, 0, 20}, {c, 0, r}] // Flatten (* _Indranil Ghosh_, Apr 02 2017 *)
%o A268833 (Scheme)
%o A268833 (define (A268833 n) (A268833bi (A002262 n) (A025581 n)))
%o A268833 (define (A268833bi row col) (A101080bi col (A268820bi row (+ row col))))
%o A268833 (PARI) b(n) = if(n<1, 0, b(n\2) + n%2);
%o A268833 A101080(n, k) = b(bitxor(n, k));
%o A268833 A003188(n) = bitxor(n, n\2);
%o A268833 A006068(n) = if(n<2, n, {my(m = A006068(n\2)); 2*m + (n%2 + m%2)%2});
%o A268833 A268820(r, c) = if(r==0, c, if(c==0, 0, A003188(1 + A006068(A268820(r - 1, c - 1)))));
%o A268833 A(r, c) = A101080(c, A268820(r, r + c));
%o A268833 for(r=0, 20, for(c=0, r, print1(A(c, r - c),", ");); print();) \\ _Indranil Ghosh_, Apr 02 2017
%o A268833 (PARI)
%o A268833 up_to = 32895; \\ = binomial(1+256,2)-1.\\ A003188 and A006068 as above.
%o A268833 A268833sq(n, k) = hammingweight(bitxor(n,A003188(k+A006068(n))));
%o A268833 A268833list(up_to) = { my(v = vector(up_to), i=0); for(a=0,oo, for(col=0,a, i++; if(i > up_to, return(v)); v[i] = A268833sq(a-col,col))); (v); };
%o A268833 v268833 = A268833list(1+up_to);
%o A268833 A268833(n) = v268833[1+n]; \\ _Antti Karttunen_, Mar 11 2024
%o A268833 (Python)
%o A268833 def A101080(n, k): return bin(n^k)[2:].count("1")
%o A268833 def A003188(n): return n^(n//2)
%o A268833 def A006068(n):
%o A268833     if n<2: return n
%o A268833     else:
%o A268833         m=A006068(n//2)
%o A268833         return 2*m + (n%2 + m%2)%2
%o A268833 def A268820(r, c): return c if r<1 else 0 if c<1 else A003188(1 + A006068(A268820(r - 1, c - 1)))
%o A268833 def a(r, c): return A101080(c, A268820(r, r + c))
%o A268833 for r in range(21):
%o A268833     print([a(c, r - c) for c in range(r + 1)]) # _Indranil Ghosh_, Apr 02 2017
%Y A268833 Transpose A268834.
%Y A268833 Main diagonal: A268835.
%Y A268833 Column 0: A005811.
%Y A268833 Row 0: A000004, Row 1: A000012, Row 2: A007395, Row 3: A268676.
%Y A268833 Cf. A003188, A006068.
%Y A268833 Cf. also A268726, A268727.
%K A268833 nonn,tabl
%O A268833 0,6
%A A268833 _Antti Karttunen_, Feb 15 2016
%E A268833 Definition simplified by _Antti Karttunen_, Mar 11 2024