Skip to content

Commit

Permalink
Add Ex 31
Browse files Browse the repository at this point in the history
  • Loading branch information
trolleyman committed Nov 19, 2015
1 parent 86d774a commit 82aaf08
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 31.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(* Determine whether two positive integer numbers are coprime. (easy)
Two numbers are coprime if their greatest common divisor equals 1. *)
(*
# coprime 13 27;;
- : bool = true
# not (coprime 20536 7826);;
- : bool = true
*)

let coprime a b =
let rec gcd a = function
| 0 -> a
| b -> gcd b (a mod b) in
(gcd a b) = 1;;

coprime 13 27;;
coprime 20536 7826;;

0 comments on commit 82aaf08

Please sign in to comment.