You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
761 B
Plaintext

app "fibonacci"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.7.1/Icc3xJoIixF3hCcfXrDwLCu4wQHtNdPyoJkEbkgIElA.tar.br" }
imports [pf.Stdout, pf.Task]
provides [main] to pf
main : Task.Task {} I32
main =
numStrings =
List.range { start: At 0u128, end: At 186u128 } # 186 is all we can do with 128 bit
|> List.walk [] fibWalk
|> List.map Num.toStr
|> Str.joinWith "\n"
Stdout.line "$(numStrings)"
fibWalk : List (Num a), Num a -> List (Num a)
fibWalk = \l, n ->
next =
when l is
[] | [_] -> fib n
[.., a, b] -> a + b
List.append l next
fib : Num a -> Num a
fib = \n ->
if n < 2 then
n
else
fib (n - 1) + fib (n - 2)