Skip to content

Instantly share code, notes, and snippets.

@jerryvig
Last active August 29, 2015 14:01
Show Gist options
  • Save jerryvig/509f29a7af78f1443592 to your computer and use it in GitHub Desktop.
Save jerryvig/509f29a7af78f1443592 to your computer and use it in GitHub Desktop.
Simple Fibonacci Algorithm in JavaScript
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