OFFSET
1,1
COMMENTS
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Gray Code.
Wikipedia, Gray code.
FORMULA
a(n) = A081706(n) + 1. - Hugo Pfoertner, May 16 2021
EXAMPLE
3 is a term since its Gray code, 10, has 1 trailing zero, and 1 is odd.
15 is a term since its Gray code, 1000, has 3 trailing zeros, and 3 is odd.
MATHEMATICA
Select[Range[180], OddQ @ IntegerExponent[# * (# + 1)/2, 2] &]
PROG
(Python)
def A344346(n):
def f(x):
c, s = (n+1>>1)+x, bin(x)[2:]
l = len(s)
for i in range(l&1^1, l, 2):
c -= int(s[i])+int('0'+s[:i], 2)
return c
m, k = n, f(n)
while m != k: m, k = k, f(k)
return (m<<2)-(n&1) # Chai Wah Wu, Jan 29 2025
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Amiram Eldar, May 15 2021
STATUS
approved