/// classical_fibonacci(n) returns the nth fibonacci number
/// This function uses the definition of Fibonacci where:
/// F(0) = 0, F(1) = 1 and F(n+1) = F(n) + F(n-1) for n>0
///
/// Warning: This will overflow the 128-bit unsigned integer at n=186


This will overflow the 128-bit unsigned integer at n=186
This will overflow the 128 - bit unsigned integer at n = 186
pub fn classical_fibonacci(n: u32) -> u128 {
    match n {
        0 => 0,
        1 => 1,
        _ => {
            let k = n / 2;
            let f1 = classical_fibonacci(k);
            let f2 = classical_fibonacci(k - 1);
            match n % 4 {
                0 | 2 => f1 * (f1 + 2 * f2),
                1 => (2 * f1 + f2) * (2 * f1 - f2) + 2,
                _ => (2 * f1 + f2) * (2 * f1 - f2) - 2,
            }
        }
    }
}
pub fn classical_fibonacci ( n : u32 ) -> u128 { match n { 0 => 0 , 1 => 1 , _ => { let k = n / 2 ; let f1 = classical_fibonacci ( k ) ; let f2 = classical_fibonacci ( k - 1 ) ; match n % 4 { 0 | 2 => f1 * ( f1 + 2 * f2 ) , 1 => ( 2 * f1 + f2 ) * ( 2 * f1 - f2 ) + 2 , _ => ( 2 * f1 + f2 ) * ( 2 * f1 - f2 ) - 2 , } } } }
classical_fibonacci(n) returns the nth fibonacci number
This function uses the definition of Fibonacci where:
F(0) = 0, F(1) = 1 and F(n+1) = F(n) + F(n-1) for n>0
classical_fibonacci ( n ) returns the nth fibonacci number This function uses the definition of Fibonacci where : F ( 0 ) = 0 F ( 1 ) = 1 and F ( n + 1 ) = F ( n ) + F ( n - 1 ) for n > 0
n
u32