csci2041/repo-zhan4854/Lab_01/fib.ml
Michael Zhang 399845160c
f
2018-01-29 17:35:31 -06:00

10 lines
286 B
OCaml

(* Author: Eric Van Wyk
Modified by: Michael Zhang *)
(* A function computing the Fibonacci sequence: 1, 1, 2, 3, 5, 8, ... *)
(* There is a bug in the following program. Can you fix it? *)
let rec fib x =
if x == 0 then 0 else
(if x < 3 then 1 else fib (x-1) + fib (x-2))