On Monday, 24 October 2016 at 08:20:26 UTC, Matthias Bentrup wrote:
PS: the exact formula is fib(n) = 1/sqrt(5) * (0.5 + 0.5sqrt(5))^n - 1/sqrt(5) * (0.5 - 0.5sqrt(5))^n. If you round to integer anyway, the second term can be ignored as it is always <= 0.5.

You can simply write it as:
round(phi^n/sqrt(5));

Check my example above :)

Reply via email to