Created
September 25, 2018 18:50
-
-
Save codewisdom/84f9374991e4a603df026b61d5833b73 to your computer and use it in GitHub Desktop.
nthFib
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 nthFibonacciP(n) { | |
let left = 0; | |
let right = 1; | |
if(n < 2) { | |
return n; | |
} | |
for(let i = 2; i <= n; i++) { | |
let temp_right = right; | |
right = left + right; | |
left = temp_right; | |
} | |
return right; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment