You are given an integer n, and your task is to count all ordered triples (a, b, c) such that:
a, b, and c are integers within the range 1 to n
They satisfy the Pythagorean-like condition:
Every valid order counts separately, meaning (a, b, c) and (b, a, c) are treated as different triples if both satisfy the condition.
Return the total number of such triples.
Input: n = 6
Output: 2
Explanation:
Valid triples are: (3, 4, 5) (4, 3, 5)
Input: n = 12
Output: 6
Explanation:
(3,4,5) (4,3,5) (6,8,10) (8,6,10) (9,12,15) — but 15 > 12 → NOT counted Thus only 6 valid triples remain.
Accepted:
Submission: