Implemented else blocks
This commit is contained in:
19
examples/gcd/gcd.q
Normal file
19
examples/gcd/gcd.q
Normal file
@ -0,0 +1,19 @@
|
||||
import log
|
||||
|
||||
main() {
|
||||
log.number(gcd(1071, 462))
|
||||
}
|
||||
|
||||
gcd(a, b) {
|
||||
loop {
|
||||
if a == b {
|
||||
return a
|
||||
}
|
||||
|
||||
if a > b {
|
||||
a -= b
|
||||
} else {
|
||||
b -= a
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user