Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fibonacci approaching Golden Ratio
var _ = require('lodash');
// Helper function for generating the nth Fibonacci number
var fibonacci = _.memoize(function(n) {
return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
});
var fibonacci_ratio = function(n) {
return fibonacci(n) / fibonacci(n - 1);
};
_.times(20, function(n) {
console.log(fibonacci_ratio(n));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.