Skip to content

Instantly share code, notes, and snippets.

@noroot
Created June 20, 2017 22:15
Show Gist options
  • Save noroot/dff42ee0e110a67ef3a0e3adb7a0456c to your computer and use it in GitHub Desktop.
Save noroot/dff42ee0e110a67ef3a0e3adb7a0456c to your computer and use it in GitHub Desktop.
Javascript Fibonacci sequence example
var f = function () {
let p = 0, n = 1,t;
return function () {
t = p;
p = n;
n += t;
return t;
};
}
let fr = f();
for (let i = 0; i<=10;i++) {
console.log(fr());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment