Modular Arithmetic
Implement the function
val modulo : int -> int -> int
so that modulo n k is n mod k. Your implementation may not use
the operator (mod), and must be tail recursive. The behavior of the
function is undefined if n is negative or if k is not positive.
Examples
let _ = assert (modulo 10 3 = 1) let _ = assert (modulo 7 7 = 0) let _ = assert (modulo 0 5 = 0)