A Pythagorean triplet is a set of three natural numbers, a
b
c, for which,
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
p9()->p9(334).
p9(C)->p9(1,C).
p9(C,C)->p9(1,C+1);
p9(B,C)->
A=1000-C-B,
if
C*C == A*A + B*B->
io:format("~w~n",[A*B*C]);
true->
p9(B+1,C)
end.
def p9
(2..500).each do |a|
(1...a).each do |b|
if(a**2+b**2==(1000-a-b)**2)
puts a*b*(1000-a-b)
return
end
end
end
end
//pow def p9{ for(c<-334 to 1000; b<-2 to (c-1)){ if(c*c==b*b+pow(1000-c-b,2).intValue) { println(c*b*(1000-c-b)) return } } }