Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def find_all_squares(n):
- squares = set()
- for i in range(1, int(math.sqrt(n)) + 1):
- a = i**2
- for j in range(i, int(math.sqrt(n)) + 1):
- b = j**2
- c = n - a - b
- if c >= 0 and c == int(c) and math.isqrt(c)**2 == c:
- squares.add(tuple(sorted([a, b, c])))
- if squares:
- return [list(sq) for sq in squares]
- else:
- return None
- print(find_all_squares(51))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement