login
a(n) = the smallest k such that Fibonacci(k) begins and ends with n, where Fibonacci(k) > n, or -1 if there are none.
0

%I #32 Aug 12 2024 09:35:46

%S 22,114,124,72,10,39,116,207,169,5715,2428,5634,2366,189,2620,4668,

%T 3137,2673,5812,12090,721,11583,20086,3798,1975,999,10636,846,2071,

%U 9105,1162,2076,8287,11091,2770,2928,12943,8493,172,2220,5359,4737,28126,11838,10460,7479,10996

%N a(n) = the smallest k such that Fibonacci(k) begins and ends with n, where Fibonacci(k) > n, or -1 if there are none.

%C Since the smallest number beginning and ending with n is the same n, the condition that Fibonacci(k) > n is imposed. Partial overlap of the start and end is allowed, but not full overlap.

%F a(n) >= max{A023183(n), A020344(n)} except that a(n) = -1 when A023183(n) = -1. - _Michael S. Branicky_, Jun 27 2024

%e As Fibonacci(22) = 17711 is the smallest Fibonacci number greater than 1 that begins and ends with 1, a(1) = 22.

%e As Fibonacci(10) = 55 is the smallest Fibonacci number greater than 5 that begins and ends with 5, a(5) = 10.

%o (PARI) isok(s,t) = my(ss=strsplit(s, t)); (#ss >= 3) && (ss[1]=="") && (ss[#ss]=="");

%o a(n) = my(k=7); while(!isok(Str(fibonacci(k)), Str(n)), k++); k; \\ _Michel Marcus_, Jun 26 2024

%o (Python) # uses A023183() in A023183

%o from itertools import count

%o def a(n):

%o if A023183(n) == -1:

%o return -1

%o f, g, s = 1, 2, str(n)

%o pow10 = 10**len(s)

%o for k in count(3):

%o if g%pow10 == n:

%o sfib = str(g)

%o if g > n and sfib.startswith(s):

%o return k

%o f, g = g, f+g

%o print([a(n) for n in range(1, 51)]) # _Michael S. Branicky_, Jul 03 2024

%Y Cf. A000045, A272623, A023183, A020344.

%K nonn,base

%O 1,1

%A _Gonzalo Martínez_, Jun 26 2024

%E More terms from _Michel Marcus_, Jun 26 2024