Created
July 1, 2013 18:12
-
-
Save chrisinajar/5903186 to your computer and use it in GitHub Desktop.
Calculate Fibonacci Sequence
This file contains 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
// 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