Skip to content

Instantly share code, notes, and snippets.

@proprietary
Created January 10, 2016 21:23
Show Gist options
  • Save proprietary/046d169c7390d7867df0 to your computer and use it in GitHub Desktop.
Save proprietary/046d169c7390d7867df0 to your computer and use it in GitHub Desktop.
/* Demo of fibs in an imperative style
* Made for benchmarking against a functional
* style equivalent code
*/
function fib(max) {
var ret = [0];
var last = 0;
var next = 1;
var temp;
do {
ret.push(next);
temp = next;
next += last;
last = temp;
} while(next < max);
return ret;
}
(function() {
let r = fib(1000);
console.log(r);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment