Created
October 30, 2012 22:17
-
-
Save masahixixi/3983467 to your computer and use it in GitHub Desktop.
ProjectEuler #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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