Data update
This commit is contained in:
parent
796d366b97
commit
35bcdeebf8
504 changed files with 7045 additions and 610 deletions
17
Task/Fibonacci-sequence/Grain/fibonacci-sequence-2.grain
Normal file
17
Task/Fibonacci-sequence/Grain/fibonacci-sequence-2.grain
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import File from "sys/file"
|
||||
let fib = j => {
|
||||
let mut fnow = 0, fnext = 1
|
||||
for (let mut n = 0; n <= j; n += 1) {
|
||||
if (n == 0 || n == 1) {
|
||||
let output1 = " " ++ toString(n)
|
||||
ignore(File.fdWrite(File.stdout, output1))
|
||||
} else {
|
||||
let tempf = fnow + fnext
|
||||
fnow = fnext
|
||||
fnext = tempf
|
||||
let output2 = " " ++ toString(fnext)
|
||||
ignore(File.fdWrite(File.stdout, output2))
|
||||
}
|
||||
}
|
||||
}
|
||||
fib(20)
|
||||
Loading…
Add table
Add a link
Reference in a new issue