Created
January 8, 2009 22:45
-
-
Save madx/44931 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment