Skip to content

Instantly share code, notes, and snippets.

@robhanlon22
Created June 6, 2012 17:35
Show Gist options
  • Save robhanlon22/2883467 to your computer and use it in GitHub Desktop.
Save robhanlon22/2883467 to your computer and use it in GitHub Desktop.
u = ->(m) do
y = ->(*a, &b) { y = ->(*a) { b.(*a, &y) } }
r = ->(n, f) do
i, g = f.()
i <= n ? [i] + r.(n, g) : []
end
r.(m, y.() { |i, j, &b| -> { [j, b.(j, i + j)] } }.(1, 1))
end
p u.(4_000_000).select(&:even?).reduce(0, :+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment