login
A231920
Working in base 3: 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.
8
0, 11, 1, 10, 100, 12, 2, 20, 101, 22, 110, 202, 220, 1000, 102, 21, 111, 122, 212, 221, 1001, 112, 121, 200, 211, 222, 1002, 120, 201, 210, 1011, 1022, 1101, 1110, 1202, 1220, 2012, 2021, 2102, 2120, 2201, 2210, 10000, 1010, 1100, 1111, 1122, 1212, 1221, 2002, 2020
OFFSET
0,2
COMMENTS
This is a permutation of the nonnegative integers in base 3 - see the Comments in A228407 for the proof.
MATHEMATICA
a[0] = 0; a[n_] := a[n] = Block[{k = 1, idm = IntegerDigits[ a[n - 1], 3], t = a@# & /@ Range[n - 1]}, Label[ start]; While[ MemberQ[t, k], k++]; While[ Select[ Permutations[ Join[ idm, IntegerDigits[k, 3]]], #[[1]] != 0 && # == Reverse@# &] == {}, k++; Goto[ start]]; k]; s = Array[a, 60, 0]; FromDigits@# & /@ IntegerDigits[s, 3]
KEYWORD
nonn,base,easy
AUTHOR
STATUS
approved