Greatest common divisor
editable example
Click the pencil to open this in an editor, change it, and run it in your browser. The same solution is posted on Rosetta Code.
ghul
use IO.Std.write_line
gcd(a: int, b: int) -> int => if b == 0 then a else gcd(b, a % b) fi
write_line("gcd(48, 18) = {gcd(48, 18)}")
write_line("gcd(1071, 462) = {gcd(1071, 462)}")
write_line("gcd(0, 13) = {gcd(0, 13)}")
write_line("gcd(13, 0) = {gcd(13, 0)}")