(* imperative version of factorial - just an example, not good style *) let fact n = let n = ref n in let m = ref 1 in let rec loop() = if !n = 0 then () else (m := !n * !m; n := !n - 1; loop()) in loop(); !m (* try fact 5;; *)