Dsa
Math
Medium
Sum of Pythagorean Triples
Given an integer n, write a function to find all unique Pythagorean triples (a, b, c) where a^2 + b^2 = c^2 and a + b + c <= n. Return the sum of all c values from the found triples.
Input Format:
A single integer n (1 <= n <= 200).
Output Format:
A single integer sum of all unique c values.
Example:
Input:
12
Output:
5
Key concepts
pythagoreantriplesgeometry
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now