Skip to content

Instantly share code, notes, and snippets.

@rinchik
Last active January 28, 2017 18:38
Show Gist options
  • Save rinchik/be87908615b59952b89088c2d9e850b2 to your computer and use it in GitHub Desktop.
Save rinchik/be87908615b59952b89088c2d9e850b2 to your computer and use it in GitHub Desktop.
FibonacciIteration.js
function fibonacci(number) {
var previous_first = 0, previous_second = 1, next = 1;
for(var i = 2; i <= number; i++) {
next = previous_first + previous_second;
previous_first = previous_second;
previous_second = next;
}
return next;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment