LibRapid / librapid

A highly optimised C++ library for mathematical applications and neural networks.
http://librapid.rtfd.io
MIT License
164 stars 10 forks source link

Added optimised nth-Fibonacci number generator. #30

Closed NervousNullPtr closed 2 years ago

NervousNullPtr commented 2 years ago

If n is less than or equal to 75 (the precision limit of the double data type), we use the formula (½(1 + √5))ⁿ / √5 to compute the nth number.

Note: As long double only needs to be at least as precise as the regular double, I set the limit to the particular number 75.