Implemented else blocks

This commit is contained in:
Eduard Urbach 2024-07-30 16:36:33 +02:00
parent ff86dfe590
commit e537e543cc
Signed by: eduard
GPG key ID: 49226B848C78F6C8
17 changed files with 118 additions and 25 deletions

View file

@ -1,7 +1,7 @@
import sys
import log
main() {
sys.exit(factorial(5))
log.number(factorial(5))
}
factorial(x) {

View file

@ -1,7 +1,7 @@
import sys
import log
main() {
sys.exit(fibonacci(10))
log.number(fibonacci(10))
}
fibonacci(x) {

19
examples/gcd/gcd.q Normal file
View 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
}
}
}