geremy condra writes:

> or O(1):
> 
> φ = (1 + sqrt(5)) / 2
> def fib(n):
>     numerator = (φ**n) - (1 - φ)**n
>     denominator = sqrt(5)
>     return round(numerator/denominator)
> 
> Testing indicates that it's faster somewhere around 7 or so.

And increasingly inaccurate from 71 on.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to