Python, 36 3434 32 bytes
f=lambdalambda n:len(str(66*n**6))//1.24
Previous versionversions:
f=lambda n:len(str(66*n**6))//1.24
f=lambda n:(n*n*7).bit_length()//1.4
Explanation
The core idea is to invert the formula
fibonacci(n) ~ ( (1 + sqrt(5)) / 2)**n / sqrt(5)
which tells us that
log fibonacci(n) ~ n log((1 + sqrt(5)) / 2) - log(sqrt(5))
to get
f(n) ~ (log(n) + log(sqrt(5))) / log((1 + sqrt(5))/2)
The golfing optimizations are:
- Use
len(str(n))to compute log base 10 without importinglog(old version used.bit_length()to compute log base 2) - Raise
nto a power, so that the approximation of the logarithm can distinguish between successive Fibonacci numbers - Multiplying by a constant scales up the values to get them in the correct range
Then the divisor was truncated to as little precision as I could manage and the multiplier chosen to give the correct results for all 32-bit fibonacci numbers.