OFFSET
1,1
COMMENTS
Zerofree numbers in balanced ternary notation can be used as reversible sign operators. This sequence collects such operators that are either in palindrome form or sign reversed palindrome form (which is defined as (n)_bt+Reverse((n)_bt)=0).
LINKS
Lei Zhou, Table of n, a(n) for n = 1..10000
EXAMPLE
2 = (1T)_bt in balanced ternary notation, where we use T to represent -1.
1T + T1 = 0, matches the definition of sign reversed palindrome form. So 2 is in the sequence.
Other examples:
7 = (1T1_bt) - palindrome; in the sequence.
13 = (111)_bt - palindrome but repdigit; not in the sequence.
16 = (1TT1)_bt - palindrome; in the sequence.
...
52 = (1T0T1)_bt - palindrome but not zerofree; not in the sequence.
MATHEMATICA
BTDigits[m_Integer, g_] :=
(* This is to determine digits of a number in balanced ternary notation. *)
Module[{n = m, d, sign, t = g}, If[n != 0, If[n > 0, sign = 1,
sign = -1; n = -n]; d = Ceiling[Log[3, n]]; If[3^d - n <= ((3^d - 1)/2), d++]; While[Length[t] < d, PrependTo[t, 0]]; t[[Length[t] + 1 - d]] = sign; t = BTDigits[sign*(n - 3^(d - 1)), t]]; t];
BTnum[g_]:=Module[{bo=Reverse[g], data=0, i}, Do[data=data+3^(i-1)*bo[[i]], {i, 1, Length[bo]}]; data];
ct=0; n=0; dg=0; spool={}; res={}; While[ct<50, n++; nbits = BTDigits[n, {0}]; cdg=Length[nbits]; If[cdg>dg, If[Length[spool]>0, Do[bits=spool[[j]]; If[!MemberQ[bits, 0], rb=Reverse[bits]; sign=rb[[1]]; bo=Join[bits, -sign*rb]; If[MemberQ[bo, -1], data=BTnum[bo]; ct++; AppendTo[res, data]]; bo=Join[bits, sign*rb]; If[MemberQ[bo, -1], data=BTnum[bo]; ct++; AppendTo[res, data]]], {j, 1, Length[spool]}]; Do[bits=spool[[j]]; If[!MemberQ[bits, 0], rb=Reverse[bits]; bo=Join[bits, {-1}, rb]; If[MemberQ[bo, -1], data=BTnum[bo]; ct++; AppendTo[res, data]]; bo=Join[bits, {1}, rb]; If[MemberQ[bo, -1], data=BTnum[bo]; ct++; AppendTo[res, data]]], {j, 1, Length[spool]}]; spool={}; dg=cdg]]; AppendTo[spool, nbits]]; Print[res]
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Lei Zhou, Dec 14 2013
STATUS
approved