Created
May 27, 2014 05:39
-
-
Save 92thunder/c1a1b3e62df1d22fd189 to your computer and use it in GitHub Desktop.
Node.js vs Ruby (Fibonacci number)
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
var sys = require('sys'); | |
function fib(n) { | |
if (n < 2) return n; | |
return fib(n-2) + fib(n-1); | |
} | |
sys.print(fib(39)); |
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
def fib n | |
return n if n < 2 | |
fib(n-2) + fib(n-1) | |
end | |
print fib(39) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment