Added more examples
This commit is contained in:
parent
2a0137c2c2
commit
9ea99c97c4
3 changed files with 29 additions and 4 deletions
22
examples/collatz/collatz.q
Normal file
22
examples/collatz/collatz.q
Normal file
|
@ -0,0 +1,22 @@
|
|||
import log
|
||||
import sys
|
||||
|
||||
main() {
|
||||
x := 12
|
||||
|
||||
loop {
|
||||
if x & 1 == 0 {
|
||||
x /= 2
|
||||
} else {
|
||||
x = 3 * x + 1
|
||||
}
|
||||
|
||||
log.number(x)
|
||||
|
||||
if x == 1 {
|
||||
return
|
||||
}
|
||||
|
||||
sys.write(1, " ", 1)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue