Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def sumOfSquares(n):
	out = []
	for i in range(1, int((n/2)**0.5) + 1):
		x = (n - i**2)**0.5
		if x == int(x):
			out.append([i, int(x)])
	return out

def sumOfSquares3(n):
	out = []
	for i in range(1, int((n/3)**0.5) + 1):
		x = n - i**2
		sum2 = sumOfSquares(int(x))
		for j in sum2:
			e = sorted((i, j[0], j[1]))
			if e not in out:
				out.append(e)
	return out

def main():
	for i in range(1000):
		sq3 = sumOfSquares3(i)
		if len(sq3) == 4:
			print str(i) + " " + str(sq3)

main()