Skip to content

Instantly share code, notes, and snippets.

@juanmaguitar
Last active September 12, 2016 11:07
Show Gist options
  • Save juanmaguitar/c330662afca8d6f55fdd398cf11e6fce to your computer and use it in GitHub Desktop.
Save juanmaguitar/c330662afca8d6f55fdd398cf11e6fce to your computer and use it in GitHub Desktop.
JS:fibonacciNth
function fibonacciNth ( position ) {
switch (position) {
case 0:
return -1;
case 1:
return 0;
case 2:
return 1;
default:
return fibonacciNth(position-1)+fibonacciNth(position-2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment