Problem 44

completed December 18, 2011

Code

upbound = 10**4
lowbound = 10**3
pentset = []
answerset = []
for n in range(lowbound, upbound):
	pentset.append(n*(3*n-1)/2)

for j in range(upbound-lowbound):
	if j%100 == 0: print j
	for k in range(j+1, upbound-lowbound):
		if k%1000 == 0: print j, k, answerset
		j1 = pentset[j]; k1 = pentset[k]
		if ((j1+k1) in pentset) and ((k1-j1) in pentset):
			answerset.append(k1-j1)
			
print sorted(answerset)