Created
October 10, 2018 18:53
-
-
Save bitsmanent/caa78ec95dc62bb39677285fa1a26711 to your computer and use it in GitHub Desktop.
fibonacci (the go way)
This file contains hidden or 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 fib() { | |
var a = 0, b = 1; | |
return function() { | |
var t = a; | |
a = b; | |
b = t + b; | |
return a; | |
}; | |
} | |
var f = fib(); | |
console.log(f(), f(), f(), f(), f()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment