login
A268676
a(n) = A101080(n,A268823(3+n)), where A101080(x,y) gives the Hamming distance between binary expansions of x and y.
3
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, 3, 3, 1, 3, 1, 1, 3, 3, 1, 1, 3, 1, 3, 3, 1, 1, 3, 3, 1, 3, 1, 1, 3, 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, 3, 3, 1, 3, 1, 1, 3, 1, 3, 3, 1, 3, 1, 1, 3, 3, 1, 1, 3, 1, 3, 3, 1, 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
OFFSET
0,2
COMMENTS
It seems that A001969 gives the positions of 1's, while A000069 gives the positions of 3's.
The above observation follows because by definition, a(n) gives the Hamming distance between binary expansions of n and A003188(3+A006068(n)). To see how this leads to the stated claim, consider the illustration "Visualized as a traversal of vertices of a tesseract" in the Wikipedia article "Gray code". Starting from any vertex with either (A) an even, or (B) an odd number of 1-bits, traverse three edges along the red path, to the direction indicated by the arrow, and then note the Hamming distance between the starting and the ending vertex. It is always 1 in case (A), and 3 in case (B), because the position of the flipped bit is given by sequence A007814, with its every other term zero, so in case (A) the third flip cancels the first flip (both toggling the rightmost bit), which leaves only the second bit-flip effective. Note that the properties of a tesseract generalize to those of an infinite dimensional hypercube. - Antti Karttunen, Mar 11 2024
LINKS
Wikipedia, Gray code.
FORMULA
a(n) = A101080(n,A268823(3+n)), where A101080(x,y) gives the Hamming distance between binary expansions of x and y.
a(n) = 2 - (-1)^A000120(n) = 2 - A106400(n). - Lorenzo Sauras Altuzarra, Mar 10 2024
a(n) = 1 + 2 * A010060(n). - Joerg Arndt, Mar 11 2024
MAPLE
a := n -> 2-(-1)^add(convert(n, base, 2)):
seq(a(n), n = 0 .. 120); # Lorenzo Sauras Altuzarra, Mar 10 2024
PROG
(Scheme) (define (A268676 n) (A101080bi n (A268823 (+ 3 n))))
;; Where A101080bi implements the dyadic function A101080(x, y) which gives the Hamming distance between binary expansions of x and y.
(PARI)
A003188(n) = bitxor(n, n>>1);
A006068(n) = { my(s=1, ns); while(1, ns = n >> s; if(0==ns, return(n)); n = bitxor(n, ns); s <<= 1); };
A268676(n) = hammingweight(bitxor(n, A003188(3+A006068(n)))); \\ Antti Karttunen, Mar 11 2024
(PARI) A268676(n) = 2-((-1)^hammingweight(n)); \\ Antti Karttunen, Mar 11 2024, after Lorenzo Sauras Altuzarra's Maple-code.
KEYWORD
nonn
AUTHOR
Antti Karttunen, Feb 19 2016
STATUS
approved