Problem 173

completed January 24, 2012

Comments

I wish this one ran faster. Not sure how I could have made that happen though. Probably using a little more math brains would have helped. Oh well. I figured, by the time I found that faster method, the slower one would have finished.

Code

count = 0
bound = 10**6

for outer in range(3, bound/4 + 2):
	if outer%1000 == 0: print outer
	for inner in range(outer-2, 0, -2):
		this = outer**2 - inner**2
		if this <= bound:
			count += 1
		if this > bound:
			break

print count