OFFSET
0,3
COMMENTS
It appears that if n is greater than 99 and congruent to 4 or 6 (mod 8) then there is no Fibonacci number ending in that n. - Jason Earls, Jun 19 2004
This is because there is no Fibonacci number == 4 or 6 (mod 8). - Robert Israel, Sep 11 2020
LINKS
Robert Israel, Table of n, a(n) for n = 0..9999
MAPLE
V:= Array(0..999, -1):
V[0]:= 0: u:= 1: v:= 0:
for n from 1 to 1500 do
t:= v;
v:= u+v mod 1000;
u:= t;
if V[v] = -1 then V[v]:= n fi;
if V[v mod 100] = -1 then V[v mod 100] := n fi;
if V[v mod 10] = -1 then V[v mod 10]:= n fi;
od:
seq(V[i], i=0..999); # Robert Israel, Sep 11 2020
MATHEMATICA
d[n_]:=IntegerDigits[n]; Table[j=0; While[Length[d[Fibonacci[j]]]<(le=Length[y=d[n]]), j++]; i=j; While[Take[d[Fibonacci[i]], -le]!=y, i++]; i, {n, 0, 65}] (* Jayanta Basu, May 18 2013 *)
PROG
(Python)
from itertools import count
def A023183(n):
if n < 2: return n
if n > 99 and n%8 in {4, 6}: return -1
k, f, g, s = 3, 1, 2, str(n)
pow10, seen = 10**len(s), set()
while (f, g) not in seen:
seen.add((f, g))
if g%pow10 == n:
return k
f, g, k = g, (f+g)%pow10, k+1
return -1
print([A023183(n) for n in range(66)]) # Michael S. Branicky, Jun 27 2024
CROSSREFS
KEYWORD
AUTHOR
STATUS
approved