Primitive Right Triangles
Count the primitive Pythagorean triples (a, b, c) with a² + b² = c², gcd(a, b, c) = 1, and hypotenuse c ≤ N.
Input: one integer N.
Output: the number of primitive triples with c ≤ N.
Constraints:
- 1 ≤ N ≤ 2×106
Sample Tests
Input 1
20
Output 1
3
Input 2
5
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.