mirror of
https://github.com/anoma/juvix.git
synced 2024-11-30 05:42:26 +03:00
17 lines
333 B
Plaintext
17 lines
333 B
Plaintext
-- Euclid's algorithm
|
|
module test025;
|
|
|
|
import Stdlib.Prelude open;
|
|
|
|
terminating
|
|
gcd : Nat → Nat → Nat
|
|
| a b :=
|
|
ite (a > b) (gcd b a) (ite (a == 0) b (gcd (mod b a) a));
|
|
|
|
main : Nat :=
|
|
gcd (3 * 7 * 2) (7 * 2 * 11)
|
|
+ gcd (3 * 7 * 2 * 11 * 5) (7 * 2 * 5)
|
|
+ gcd 3 7
|
|
+ gcd 7 3
|
|
+ gcd (11 * 7 * 3) (2 * 5 * 13);
|