Skip to content

Instantly share code, notes, and snippets.

@codewisdom
Created September 25, 2018 18:50
Show Gist options
  • Save codewisdom/84f9374991e4a603df026b61d5833b73 to your computer and use it in GitHub Desktop.
Save codewisdom/84f9374991e4a603df026b61d5833b73 to your computer and use it in GitHub Desktop.
nthFib
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