I am doing this Project Euler Question #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\$.
I have implemented the code but I feel like it runs slow and doesn't perform well enough:
def check_pathagorean(a, b, c): return (a**2) + (b**2) == (c**2) SUM = 1000 for i in range(1, SUM): for j in range(i+1, SUM): c = SUM - (i + j) if(check_pathagorean(i, j, c)): if i + j + c == SUM: print i * j * c break
What could I do to make this run faster and better?