OFFSET
1,1
LINKS
EXAMPLE
The first terms in decimal and in binary, alongside A005811(n), are:
n a(n) bin(n) bin(a(n)) A005811(n)
-- ---- ------ --------- ----------
1 3 1 11 1
2 4 10 100 2
3 7 11 111 1
4 6 100 110 2
5 9 101 1001 3
6 8 110 1000 2
7 15 111 1111 1
8 12 1000 1100 2
9 11 1001 1011 3
10 18 1010 10010 4
11 13 1011 1101 3
12 14 1100 1110 2
PROG
(PARI) a(n) = my (r=hammingweight(bitxor(n, n>>1))); for (k=n+1, oo, if (r==hammingweight(bitxor(k, k>>1)), return (k)))
(Python)
def runs(n): return bin(n^(n>>1)).count('1')
def a(n):
nruns, m = runs(n), n + 1
while runs(m) != nruns: m += 1
return m
print([a(n) for n in range(1, 67)]) # Michael S. Branicky, Feb 24 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Feb 24 2021
STATUS
approved