Skip to content

Instantly share code, notes, and snippets.

@owen-d
Created November 2, 2015 19:21
Show Gist options
  • Save owen-d/015a517f46ad80092629 to your computer and use it in GitHub Desktop.
Save owen-d/015a517f46ad80092629 to your computer and use it in GitHub Desktop.
ez fibonacci
function fib() {
var head = 0;
var tail = 0;
return function() {
var res = head + tail;
//just for the beginning, so we get 2 rounds with a result of 1
if (!res) {
head = 1;
return head;
}
tail = head;
head = res;
return res;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment