Problem 9
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc.
#!/usr/bin/ruby
sum = 1000
found = false
# Brute force
for a in 1..sum
for b in 1..sum
c = sum - a - b
if (a*a + b*b) == (c*c)
found = true
break
end
end
if found
break
end
end
puts "a: " + a.to_s + " b: " + b.to_s + " c: " + c.to_s + " product: " + (a*b*c).to_s