login
a(n) is the smallest number larger than a(n-1) with mutual Hamming distance 2 and a(1)=0.
5

%I #36 Jul 07 2021 11:25:49

%S 0,3,5,6,10,12,15,23,27,29,30,46,54,58,60,63,95,111,119,123,125,126,

%T 190,222,238,246,250,252,255,383,447,479,495,503,507,509,510,766,894,

%U 958,990,1006,1014,1018,1020,1023,1535,1791,1919,1983,2015,2031,2039,2043

%N a(n) is the smallest number larger than a(n-1) with mutual Hamming distance 2 and a(1)=0.

%C The binary expansion of a(n) has an even number of 1's. So this is a subsequence of A001969. The odd analog is A206853.

%C This sequence has 4*k+1 = A016813(k) numbers with exactly 2*k 1's and no number with more than two 0's in their binary expansion.

%H Alois P. Heinz, <a href="/A207063/b207063.txt">Table of n, a(n) for n = 1..20000</a>

%e | n | a(n) | A007088(a(n))| A000120(a(n))|

%e +---+------+--------------+--------------+

%e | 1 | 0 | 0 | 0 |

%e | 2 | 3 | 11 | 2 |

%e | 3 | 5 | 101 | 2 |

%e | 4 | 6 | 110 | 2 |

%e | 5 | 10 | 1010 | 2 |

%e | 6 | 12 | 1100 | 2 |

%e | 7 | 15 | 1111 | 4 |

%e | 8 | 23 | 10111 | 4 |

%p g:= proc(n) option remember; local l; l:= g(n-1);

%p `if`(nops(l)=1, [l[1]+1, l[1]-1], `if`(nops(l)=2,

%p `if`(l[2]<>0, [l[1], l[2]-1], [l[1]+1, 0, l[1]-1]),

%p `if`(l[3]<>1, [l[1], l[2], l[3]-1], [l[1]])))

%p end: g(1):= [2, 0, 1]:

%p a:= n-> (l-> 2^l[1]-1 -add(2^l[i], i=2..nops(l)))(g(n)):

%p seq(a(n), n=1..300);

%o (Python)

%o def aupton(terms):

%o alst = [0]

%o for n in range(2, terms+1):

%o an = alst[-1] + 1

%o while bin(an^alst[-1]).count('1') != 2: an += 1

%o alst.append(an)

%o return alst

%o print(aupton(54)) # _Michael S. Branicky_, Jul 07 2021

%Y Cf. A182187 (next with Hamming distance 2), A206853 (iterate from 1).

%Y Cf. A000120, A001969, A007088, A016813.

%K nonn,base

%O 1,2

%A _Alois P. Heinz_, Feb 14 2012