Pre-compute the Fibonacci numbers up to some bound, and then you might be able to search the list for your number more efficiently than by using linear search.
The Fibonacci numbers grow so quickly that I doubt storing them will constitute a problem. I mean, if you're willing to save the first 100 or so, that will cover all numbers up to 3.5e+20.
Say you store the first M
Fibonacci numbers. Then the worst-case using binary search is log(M)
. There are formulae for calculating the M
th Fibonacci number given M
; you could use this to approximate M
given the M
th Fibonacci number both to get the bound in terms of the number (N
, rather than the list size M
). I think this makes it end up being something like log(log(N))
, but you should check me on that.