pub fn nth_fibonacci(n: u128) -> u128
Expand description

Computes th nth fibonacci number (up to 186th) accurately using the fastest available computing method.

Arguments

  • n - the nth-fibonacci number to be computed.

How does it work?

This function uses the function φⁿ ÷ √5 for all numbers n < 76, as this is the maximum precision for that formula. For every number above that, it uses the iterative approach.

Examples

use lib_rapid::math::general::nth_fibonacci;
 
assert_eq!(1304969544928657, nth_fibonacci(74));
assert_eq!(332825110087067562321196029789634457848, nth_fibonacci(186));