exception Input_Negativo;; (* versão terminal recursiva *) let rec fib_fast x acc1 acc2 = if x<0 then raise Input_Negativo else if x = 0 then acc1 else if x = 1 then acc2 else fib_fast (x-1) acc2 (acc2+acc1) let () = let () = print_string "Introduza um inteiro" in let n = read_int () in Printf.printf " --> %d\n" (fib_fast n 1 1)
This document was generated using caml2html