Improved gcd example

This commit is contained in:
Eduard Urbach 2024-08-03 23:32:47 +02:00
parent 57ee65abd1
commit 3ad9510421
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0

View File

@ -6,14 +6,10 @@ main() {
gcd(a, b) { gcd(a, b) {
loop { loop {
if a == b { switch {
return a a == b { return a }
} a > b { a -= b }
_ { b -= a }
if a > b {
a -= b
} else {
b -= a
} }
} }
} }