let rec fib n = if n > 1 then fib(n-1) + fib (n-2) else 1;;
let _ =
if Array.length Sys.argv > 1
then
try
let n = int_of_string Sys.argv.(1) in
print_int (fib n);
print_newline()
with Invalid_argument _ ->
prerr_string "Expect one argument";
prerr_newline();
exit 1
else
begin
prerr_string "Argument should be an integer";
prerr_newline();
exit 1
end
;; |
|