let rec fib n = match n with | 1 | 2 -> 1 | _ -> (fib (n-1)) + (fib (n-2)) let fast_fib n = let rec h n pp p = match n with | 1 -> p | _ -> h (n-1) p (pp+p) in h n 0 1 let rec first_neg_fib n = let acc = fast_fib n in if acc < 0 then n else first_neg_fib (n+1)