# Count Square Sum Triples (LeetCode 1925) Loop over a and b, check whether a*a + b*b is a perfect square not above n. ```python from math import isqrt def countTriples(n): cnt = 0 for a in range(1, n + 1): for b in range(1, n + 1): c = isqrt(a*a + b*b) if c <= n and c*c == a*a + b*b: cnt += 1 return cnt ``` Interview coming up? Try [Linkjob AI copilot](https://www.linkjob.ai/). (Affiliation: I work on Linkjob AI.)
Save
ctrl + s
New
ctrl + n
Duplicate
ctrl + d
Raw
ctrl + shift + r
Github
Support this project
markdown
5