Skip to content

Instantly share code, notes, and snippets.

@ZackFox
Last active April 7, 2019 08:59
Show Gist options
  • Select an option

  • Save ZackFox/c3c51a57e2941a4fcaaa28c82e409d22 to your computer and use it in GitHub Desktop.

Select an option

Save ZackFox/c3c51a57e2941a4fcaaa28c82e409d22 to your computer and use it in GitHub Desktop.
function fibonacci(n){
if (n <= 1) return n;
let a = 0, b = 1, res;
for(let i = 1; i < n; i++){
res = a + b;
a = b;
b = res;
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment