Skip to content

Instantly share code, notes, and snippets.

@passcod
Created February 9, 2013 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save passcod/4744632 to your computer and use it in GitHub Desktop.
Save passcod/4744632 to your computer and use it in GitHub Desktop.
Fibonacci bench
function fib(n) {
return n < 2 ? n : fib(n-1) + fib(n-2);
}
print(fib(35));
# Python 2
def fib(n):
if (n < 2):
return n
else:
return fib(n-1) + fib(n-2)
print fib(35)
def fib n
if n < 2
n
else
fib(n-1) + fib(n-2)
end
end
puts fib 35
# Python 3
def fib(n):
if (n < 2):
return n
else:
return fib(n-1) + fib(n-2)
print(fib(35))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment