Implemented else blocks
This commit is contained in:
parent
5abe8acc70
commit
323952f4bc
17 changed files with 118 additions and 25 deletions
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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue