Last active
May 10, 2016 13:56
-
-
Save bokutin/d7933f8d68a3d49208c1de35c4e2e7a6 to your computer and use it in GitHub Desktop.
This file contains 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
https://fengmk2.github.io/blog/2011/fibonacci/nodejs-python-php-ruby-lua.html | |
% which python2.7 | |
/opt/local/bin/python2.7 | |
% python2.7 -V | |
Python 2.7.11 | |
% time python2.7 fib.py | |
102334155 | |
python2.7 fib.py 61.28s user 0.34s system 98% cpu 1:02.31 total | |
% which ruby | |
/Users/bokutin/.rbenv/shims/ruby | |
% ruby -v | |
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0] | |
% time ruby fib.rb | |
102334155 | |
ruby fib.rb 21.19s user 0.18s system 98% cpu 21.688 total | |
% which perl | |
/Users/bokutin/perl5/perlbrew/perls/perl-5.16.2/bin/perl | |
% perl -v | grep version | |
This is perl 5, version 16, subversion 2 (v5.16.2) built for darwin-thread-multi-2level | |
% time perl fib2.pl | |
102334155 | |
perl fib2.pl 99.35s user 0.57s system 98% cpu 1:41.72 total | |
% which perl5.24.0 | |
/Users/bokutin/perl5/perlbrew/perls/perl-5.24.0/bin/perl5.24.0 | |
% perl5.24.0 -v | grep version | |
This is perl 5, version 24, subversion 0 (v5.24.0) built for darwin-2level | |
% time perl5.24.0 fib2.pl | |
102334155 | |
perl5.24.0 fib2.pl 78.93s user 0.34s system 99% cpu 1:19.75 total | |
% cat fib2.pl | |
sub fibonacci { | |
return $_[0] if $_[0] < 2; | |
return fibonacci($_[0] - 2) + fibonacci($_[0] - 1); | |
} | |
print fibonacci(40), "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment