A Pythagorean triplet is a set of three natural numbers, a b c, for which,python
For example, 32 + 42 = 9 + 16 = 25 = 52.code
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.blog
a = 0 b = 0 c = 0 totalSum = 1000 cMax = int(totalSum/2) cMin = int(totalSum/3) aMax = cMin c = cMax while c > cMin: b = c - 1 while b > 1: a = totalSum - c - b if a > b or a < 1 or a > aMax: break if a*a + b*b == c*c: print(a, b, c) print(a*b*c) break b -= 1 c -= 1