Skip to content

Instantly share code, notes, and snippets.

@madx
Created January 8, 2009 22:45
Show Gist options
  • Save madx/44931 to your computer and use it in GitHub Desktop.
Save madx/44931 to your computer and use it in GitHub Desktop.
int fib(n) {
if(n <= 1)
return 1;
else
return fib(n-1)+fib(n-2);
}
int main() {
fib(30);
return 0;
}
/*
~/tmp $ time ./fib
real 0m0.042s
user 0m0.036s
sys 0m0.000s
*/
fib = (n):
if (n <= 1): 1. else: fib (n - 1) + fib (n - 2)..
fib (30)
~/repos/why/potion (mine) $ time ./potion example/fib.pn
real 0m0.180s
user 0m0.172s
sys 0m0.004s
def fib(n)
if n <= 1 then 1 else fib(n-1)+fib(n-2) end
end
fib(30)
=begin
~/tmp $ time ruby fib.rb
real 0m3.641s
user 0m3.248s
sys 0m0.348s
~/tmp $ time ruby1.9 fib.rb
real 0m1.309s
user 0m1.028s
sys 0m0.020s
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment