Last active
September 12, 2016 11:07
-
-
Save juanmaguitar/c330662afca8d6f55fdd398cf11e6fce to your computer and use it in GitHub Desktop.
JS:fibonacciNth
This file contains hidden or 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 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