let fib_mod n m = let a = ref 0 in let b = ref 1 in for _ = 1 to n do let c = (!a + !b) mod m in a := !b; b := c done; !a ;; fib_mod 100 1000003