login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 8
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, 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, 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 (list; table; graph; refs; listen; history; text; internal format)
OFFSET
0,6
COMMENTS
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
LINKS
Wikipedia, Gray code.
FORMULA
A(row,col) = A101080(col, A268820(row, row+col)).
A(n, k) = A101080(k, A003188(n+A006068(k))). - Antti Karttunen, Mar 11 2024
EXAMPLE
The top left [0 .. 24] X [0 .. 24] section of the array:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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Indranil Ghosh, Apr 02 2017 *)
PROG
(Scheme)
(define (A268833 n) (A268833bi (A002262 n) (A025581 n)))
(define (A268833bi row col) (A101080bi col (A268820bi row (+ row col))))
(PARI) b(n) = if(n<1, 0, b(n\2) + n%2);
A101080(n, k) = b(bitxor(n, k));
A003188(n) = bitxor(n, n\2);
A006068(n) = if(n<2, n, {my(m = A006068(n\2)); 2*m + (n%2 + m%2)%2});
A268820(r, c) = if(r==0, c, if(c==0, 0, A003188(1 + A006068(A268820(r - 1, c - 1)))));
A(r, c) = A101080(c, A268820(r, r + c));
for(r=0, 20, for(c=0, r, print1(A(c, r - c), ", "); ); print(); ) \\ Indranil Ghosh, Apr 02 2017
(PARI)
up_to = 32895; \\ = binomial(1+256, 2)-1.\\ A003188 and A006068 as above.
A268833sq(n, k) = hammingweight(bitxor(n, A003188(k+A006068(n))));
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); };
v268833 = A268833list(1+up_to);
A268833(n) = v268833[1+n]; \\ Antti Karttunen, Mar 11 2024
(Python)
def A101080(n, k): return bin(n^k)[2:].count("1")
def A003188(n): return n^(n//2)
def A006068(n):
if n<2: return n
else:
m=A006068(n//2)
return 2*m + (n%2 + m%2)%2
def A268820(r, c): return c if r<1 else 0 if c<1 else A003188(1 + A006068(A268820(r - 1, c - 1)))
def a(r, c): return A101080(c, A268820(r, r + c))
for r in range(21):
print([a(c, r - c) for c in range(r + 1)]) # Indranil Ghosh, Apr 02 2017
CROSSREFS
Transpose A268834.
Main diagonal: A268835.
Column 0: A005811.
Row 0: A000004, Row 1: A000012, Row 2: A007395, Row 3: A268676.
Cf. also A268726, A268727.
Sequence in context: A091064 A275760 A293388 * A293386 A322522 A168121
KEYWORD
nonn,tabl
AUTHOR
Antti Karttunen, Feb 15 2016
EXTENSIONS
Definition simplified by Antti Karttunen, Mar 11 2024
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 18:04 EDT 2024. Contains 371254 sequences. (Running on oeis4.)