A230891 Working in base 2: a(0)=0, thereafter a(n+1) is the smallest number not already in the sequence such that the bits of a(n) and a(n+1) together can be rearranged to form a palindrome.
0, 11, 1, 10, 100, 111, 1000, 101, 110, 1001, 1010, 1100, 1111, 10000, 1011, 1101, 1110, 10001, 10010, 10100, 10111, 11000, 11011, 11101, 11110, 100000, 10011, 10101, 10110, 11001, 11010, 11100, 11111, 100001, 100010, 100100, 100111, 101000, 101011, 101101, 101110, 110000, 110011, 110101, 110110, 111001
Offset: 0
Links
- Chai Wah Wu, Table of n, a(n) for n = 0..30000 (terms 0..1024 from Robert G. Wilson v).
Programs
-
Mathematica
a[0] = 0; a[n_] := a[n] = Block[{k = 1, idm = IntegerDigits[ a[n - 1], 2], t = a@# & /@ Range[n - 1]}, Label[ start]; While[ MemberQ[t, k], k++]; While[ Select[ Permutations[ Join[idm, IntegerDigits[k, 2]]], #[[1]] != 0 && # == Reverse@# &] == {}, k++; Goto[start]]; k]; s = Array[a, 46, 0]; FromDigits@# & /@ IntegerDigits[s, 2] (* Robert G. Wilson v, Dec 31 2013 *) -
Python
from collections import Counter A230891_list, l, s, b = [0, 11], Counter('11'), 1, {3} for _ in range(30001): i = s while True: if i not in b: li, o = Counter(bin(i)[2:]), 0 for d in (l+li).values(): if d % 2: if o > 0: break o += 1 else: A230891_list.append(int(bin(i)[2:])) l = li b.add(i) while s in b: b.remove(s) s += 1 break i += 1 # Chai Wah Wu, Jun 19 2016
Comments