Skip to content

Instantly share code, notes, and snippets.

@mwunsch
Created January 15, 2014 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwunsch/8428864 to your computer and use it in GitHub Desktop.
Save mwunsch/8428864 to your computer and use it in GitHub Desktop.
fibRecurse := method(n,
if(n == 0, 0,
if(n == 1, 1,
fibRecurse(n-1) + fibRecurse(n - 2)
)
)
)
fibLoop := method(n,
i := 0 ; a := 0 ; b := 1
while(i <= n,
old := a
a = a + b
b = old
i = i + 1
)
b
)
fibRecurse(8) println
fibLoop(8) println
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment