-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86d774a
commit 82aaf08
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;; |