Last active
August 29, 2015 14:01
-
-
Save jerryvig/509f29a7af78f1443592 to your computer and use it in GitHub Desktop.
Simple Fibonacci Algorithm in JavaScript
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
function fib(n) { | |
//Other checks to validate the input go here. | |
//Assume n is a integer greater than or equal to zero if we get here. | |
return (n === 0 || n == 1) ? 1 : (fib(n-1) + fib(n-2)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment