OFFSET
0,5
COMMENTS
Any two nonnegative integers F0 and F1 generate a Fibonacci-like sequence where for n > 1, Fn = F[n-1] + F[n-2]. Call F0 + F1 the "index" of such a sequence. In this sequence, a(n) is the smallest occurring index of any Fibonacci-like sequence containing n.
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 0..10000
FORMULA
a(n) <= A054495(n) <= n. - Charles R Greathouse IV, Nov 06 2014
EXAMPLE
For n = 0, the trivial sequence 0, 0, 0, ... has index 0.
For n = 5, the classic Fibonacci sequence 0, 1, 1, 2, 3, 5, ... contains 5 and has index 1.
For n = 7, the Lucas sequence 2, 1, 3, 4, 7, ... contains 7, and no such sequence with a smaller index contains 7.
MATHEMATICA
a[n_] := Module[{a, k, A, B}, If[n<2, Return[n]]; For[k=1, k <= n-1, k++, For[a=0, a <= k-1, a++, A=a; B=k-A; While[B<n, {A, B} = {B, A+B}]; If[B == n, Return[k]]]]; n]; Array[a, 101, 0] (* Jean-François Alcover, Jan 06 2017, translated from PARI *)
PROG
(Haskell)
bi x y = if (x<y) then (x+y) else (bi y (x-y))
a249783 0 = 0
a249783 n = minimum (map (bi n) [0..(n-1)])
(PARI) a(n)=if(n<2, return(n)); for(k=1, n-1, for(a=0, k-1, my(A=a, B=k-A); while(B<n, [A, B]=[B, A+B]); if(B==n, return(k)))); n \\ Charles R Greathouse IV, Nov 06 2014
CROSSREFS
KEYWORD
AUTHOR
Allan C. Wechsler, Nov 05 2014
EXTENSIONS
Extended by Charles R Greathouse IV, Nov 06 2014
STATUS
approved