A268676 a(n) = A101080(n,A268823(3+n)), where A101080(x,y) gives the Hamming distance between binary expansions of x and y.
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
Keywords
Links
- Antti Karttunen, Table of n, a(n) for n = 0..8191
- Wikipedia, Gray code.
Crossrefs
Programs
-
Maple
a := n -> 2-(-1)^add(convert(n, base, 2)): seq(a(n), n = 0 .. 120); # Lorenzo Sauras Altuzarra, Mar 10 2024
-
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.
-
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.
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) = 1 + 2 * A010060(n). - Joerg Arndt, Mar 11 2024
Comments