Skip to content

Instantly share code, notes, and snippets.

@victorquinn
Last active December 26, 2015 15:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save victorquinn/7175655 to your computer and use it in GitHub Desktop.
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