Skip to content

Instantly share code, notes, and snippets.

@chrisinajar
Created July 1, 2013 18:12
Show Gist options
  • Save chrisinajar/5903186 to your computer and use it in GitHub Desktop.
Save chrisinajar/5903186 to your computer and use it in GitHub Desktop.
Calculate Fibonacci Sequence
// calculate up until e
function fibb(e) {
var i = 0;
(function(le) {
return (function(f) {
return f(f);
}(function(f) {
return le(function(x) {
return f(f)(x);
});
}));
}(function(f) {
if (i === 0) {
i += 1;
return f(i);
}
return function(j) {
i += j = (i - j);
console.log(j); // print
if (j < e) return f(j);
return i + j;
}
}))
};
// test it
fibb(100);
fibb(1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment