csci2041/public-class-repo/SamplePrograms/gcd.ml
Michael Zhang 399845160c
f
2018-01-29 17:35:31 -06:00

8 lines
197 B
OCaml

let gcd m n =
let smallest = if m < n then m else n
in
let rec helper guess =
if m mod guess = 0 && n mod guess = 0 then guess
else helper (guess - 1)
in helper smallest