Skip to content

Instantly share code, notes, and snippets.

@Celestz
Last active December 12, 2023 09:32
Show Gist options
  • Save Celestz/53728451d9920ce12b420904eee6eb3d to your computer and use it in GitHub Desktop.
Save Celestz/53728451d9920ce12b420904eee6eb3d to your computer and use it in GitHub Desktop.
Fib Straight forward
// 0 1 1 2 3 5 8 13 21 34
function fibValue(index) {
let [prev, next] = [0, 1]
if (index < 2) {
return index
}
for (var x = 2; x < index; x++) {
const result = prev + next
prev = next
next = result
}
return prev + next
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment