Skip to content

Instantly share code, notes, and snippets.

@wheresalice
Created May 3, 2011 12:01
Show Gist options
  • Save wheresalice/953213 to your computer and use it in GitHub Desktop.
Save wheresalice/953213 to your computer and use it in GitHub Desktop.
Fibonacci series in Io language
#!/usr/bin/env io
fib := method(
a := 0
b := 1
for(i, 1, doMessage(call message argAt(0)) - 1, c := a + b; a := b; b := c)
)
fib(10) println
@zobnin
Copy link

zobnin commented Feb 26, 2024

More readable version:

fib := method(arg, 
    a := 0
    b := 1
    for(i, 1, arg - 1, 
        tmp := a + b
        a := b
        b := tmp
    )
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment