Pythagorean Triples
Count the triples of integers (a, b, c) with 1 <= a, b, c <= n and a*a + b*b == c*c. The order of a and b matters, so (3, 4, 5) and (4, 3, 5) are two different triples.
Example 1
n 10
returns 4
(3,4,5), (4,3,5), (6,8,10), (8,6,10).
Constraints
1 <= n <= 50
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.