9.py 378 B

123456789101112131415161718
  1. N = 800
  2. pythlist = []
  3. for x in range(N):
  4. y = x+1
  5. z = y+1
  6. while z <= N:
  7. while z * z < x * x + y * y:
  8. z = z + 1
  9. if z * z == x * x + y * y and z <= N:
  10. if x != 0 and y != 0 and z != 0:
  11. pythlist.append([x, y, z])
  12. y = y + 1
  13. for triplet in pythlist:
  14. tripsum = triplet[0] + triplet[1] + triplet[2]
  15. if tripsum == 1000:
  16. print(triplet[0] * triplet[1] * triplet[2])