Skip to content

Instantly share code, notes, and snippets.

@stringbot
Last active December 10, 2015 13:28
Show Gist options
  • Save stringbot/4440653 to your computer and use it in GitHub Desktop.
Save stringbot/4440653 to your computer and use it in GitHub Desktop.
The Fibonacci Promotion Schedule Generator
require 'active_support/time'
start = "2012-11-30"
gens = 20
def fib_series(accum,limit)
accum ||= [1,1]
return accum if accum.length >= limit
this = accum[-1]
last = accum[-2]
fib_series((accum << last + this), limit)
end
dates = fib_series(nil,gens).inject([Date.parse(start)]) do |accumulator,duration|
accumulator << accumulator.last + duration.days
end
puts dates
@stringbot
Copy link
Author

20 generations will probably exceed my lifetime, and 60 generations far exceeds the estimated lifetime of the Sun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment