Last active
January 28, 2017 18:38
-
-
Save rinchik/be87908615b59952b89088c2d9e850b2 to your computer and use it in GitHub Desktop.
FibonacciIteration.js
This file contains 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 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