Created
February 23, 2015 03:10
-
-
Save navio/6a017fa1b4c3cc900dc5 to your computer and use it in GitHub Desktop.
Linear Fibonacci, Javascript
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 runner(){ | |
var a = 0; | |
var b = 1; | |
return function fibonacci(){ | |
var c = a + b; | |
a = b; b = c; | |
print = function(){ console.log(c); }; | |
return { c: c, print: print, }; | |
}; | |
} | |
var f = new runner(); | |
for (var a = 0, myF = f(); a < 20; a++, myF = f() ){ | |
myF.print(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment