Skip to content

Instantly share code, notes, and snippets.

@kristenmills
Created May 29, 2012 22:37
Show Gist options
  • Save kristenmills/2831204 to your computer and use it in GitHub Desktop.
Save kristenmills/2831204 to your computer and use it in GitHub Desktop.
Project Euler 243
def resiliance limit = Rational(15499,94744)
list = prime_sieve(23)
sum = list.map{|x| 1-1.0/x}.reduce(:*)
val = list.reduce(:*)
phi = val * sum/(val-1)
while phi > limit
list << 2
val = list.reduce(:*)
phi = val * sum/(val-1)
end
val
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment