Count Square Sum Triples

A square triple (a, b, c) is a triple where a, b, and c are integers and a^2 + b^2 = c^2.

Given an integer n, return the number of square triples such that 1 <= a, b, c <= n.

Example 1
Inputn = 5
Output2
The square triples are (3, 4, 5) and (4, 3, 5).
Example 2
Inputn = 10
Output4
The square triples are (3, 4, 5), (4, 3, 5), (6, 8, 10), and (8, 6, 10).

Constraints

  • 1 <= n <= 250

Asked at 5 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate