Skip to content

Instantly share code, notes, and snippets.

@masahixixi
Created October 30, 2012 22:17
Show Gist options
  • Save masahixixi/3983467 to your computer and use it in GitHub Desktop.
Save masahixixi/3983467 to your computer and use it in GitHub Desktop.
ProjectEuler #9
sum = 1000
catch (:done) do
(1..(sum / 3 - 1)).each do |a|
((a+1)..(sum - a) / 2 - 1).each do |b|
c = sum - a - b
if (a**2 + b**2 == c**2) && (a + b + c == sum)
p a, b, c
p ans = a * b * c
throw :done
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment