Your approach is an unrefined "brute force" method, which uses nested loops. So the code inside all three loops gets executed 1000 times for c, which gets executed 1000 times for b, which gets executed 1000 times for a: which means that to work out the number of times the first
if
test is executed is simple, just multipole 1000 by 1000 by 1000: 1,000,000,000 - one billion times. No matter how fast your processor, no matter how quick the code inside all three loops is, that's going to take significant time. And if it finds a result on the first try - which it won't, but bear with me - it will still do the remaining 999,999,999 iterations before it finished.
Think about the algorithm better: is there a way you can reduce the number of values significantly? Well yes. For starters you can eliminate the inner loop because you know that a + b + c = 1000, therefore c = 1000 - (a + b). For every combination of a and b, c is a fixed value so you don't need to loop at all! Suddenly, you are down to 1,000,000 tests, and they are simpler. Add code to exit if you find the right result and that chops out more loops.
And that's before you start using actual formulae to solve it:
Pythagorean triple - Wikipedia[
^]
Seriously - this is your homework, not ours: dump teh brute force approach, and think about more intelligent solutions. And the quickest solution is absolutely simple:
print "375^2 + 200^2 = 425^2\n"
That won't get you any marks, though. :laugh: