login
Integers k whose Zeckendorf representation A014417(k) is palindromic.
30

%I #39 Mar 22 2021 03:41:49

%S 0,1,4,6,9,12,14,22,27,33,35,51,56,64,74,80,88,90,116,127,145,158,174,

%T 184,197,203,216,232,234,276,294,326,368,378,399,425,441,462,472,493,

%U 519,525,546,572,588,609,611,679,708,760,828,847,915,944,988,1022,1064,1090

%N Integers k whose Zeckendorf representation A014417(k) is palindromic.

%D C. G. Lekkerkerker, Voorstelling van natuurlijke getallen door een som van getallen van Fibonacci, Simon Stevin vol. 29, 1952, pages 190-195.

%D E. Zeckendorf, Représentation des nombres naturels par une somme de nombres de Fibonacci ou de nombres de Lucas, Bulletin de la Société Royale des Sciences de Liège vol. 41 (1972) pages 179-182.

%H Alois P. Heinz, <a href="/A094202/b094202.txt">Table of n, a(n) for n = 1..20000</a> (first 129 terms from Indranil Ghosh)

%H Ron Knott, <a href="http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibrep.html">Fibonacci Bases</a>.

%e Fibonacci base columns are ...,8,5,3,2,1 with column entries 0 or 1 and no two consecutive ones (the Zeckendorf representation) so that each n has a unique representation.

%e 12 is in the sequence because 12 = 8 + 3 + 1 = 10101 base Fib; 14 = 13 + 1 = 100001 base Fib.

%t zeck[n_Integer] := Block[{k = Ceiling[ Log[ GoldenRatio, n*Sqrt[5]]], t = n, fr = {}}, While[k > 1, If[t >= Fibonacci[k], AppendTo[ fr, 1]; t = t - Fibonacci[k], AppendTo[fr, 0]]; k-- ]; FromDigits[fr]]; a = {}; Do[z = zeck[n]; If[ FromDigits[ Reverse[ IntegerDigits[z]]] == z, AppendTo[a, n]], {n, 1123}]; a (* _Robert G. Wilson v_, May 29 2004 *)

%t mirror[dig_, s_] := Join[dig, s, Reverse[dig]]; select[v_, mid_] := Select[v, Length[#] == 0 || Last[#] != mid &]; fib[dig_] := Plus @@ (dig * Fibonacci[Range[2, Length[dig] + 1]]); pals = Rest[IntegerDigits /@ FromDigits /@ Select[Tuples[{0, 1}, 7], SequenceCount[#, {1, 1}] == 0 &]]; Union@Join[{0, 1}, fib /@ Join[mirror[#, {}] & /@ (select[pals, 1]), mirror[#, {1}] & /@ (select[pals, 1]), mirror[#, {0}] & /@ pals]] (* _Amiram Eldar_, Jan 11 2020 *)

%o (Python)

%o from sympy import fibonacci

%o def a(n):

%o k=0

%o x=0

%o while n>0:

%o k=0

%o while fibonacci(k)<=n: k+=1

%o x+=10**(k - 3)

%o n-=fibonacci(k - 1)

%o return x

%o def ok(n):

%o x=str(a(n))

%o return x==x[::-1]

%o print([n for n in range(1101) if ok(n)]) # _Indranil Ghosh_, Jun 07 2017

%Y Cf. A014417, A035517.

%Y Gives the positions of zeros in A095734. Subsets: A095730, A048757. A006995 gives the integers whose binary expansion is palindromic.

%K nonn,base

%O 1,3

%A _Ron Knott_, May 25 2004

%E More terms from _Robert G. Wilson v_, May 28 2004

%E Offset changed to 1 by _Alois P. Heinz_, Aug 02 2017