2 ms·
A function that calculates Fibonacci is used as an example. Just a reminder that if you want to calculate the nth Fibonacci number you can use Binet's formula.
by 29athrowaway 6y ago
A function that calculates Fibonacci is used as an example. Just a reminder that if you want to calculate the nth Fibonacci number you can use Binet's formula.
https://mathworld.wolfram.com/BinetsFibonacciNumberFormula.html https://mathworld.wolfram.com/BinetsFibonacciNumberFormula.h...
- aitchnyu 6y agoIf I implement this with floating point numbers, will I get the correct integer value?
- user-the-name 6y agoIn general, no.
- frongpik 6y agoThe caveat is that computing this formula with enough precision to get the correct result needs as many steps as the recursive algorithm.