# Pythagorean bliss

**Number Theory**Level 4

Let \(p\) be a prime number of the form \(p = 4n + 1\) (\(n \in \mathbb N\)).

How many different right triangles exist with integer lengths for their legs, such that the hypotenuse is \(p\)?

That is, how many unordered pairs of positive integers \(\{a, b\}\) exist such that \(a^2 + b^2 = p^2\)?

**Example**

If \(p = 17\), there is only one pair: \(\{8, 15\}\), because the 8-15-17 triangle is the only kind of right triangle with integer sides and hypotenuse equal to 17.

On the other hand, for \(p = 65\) we have two options: a 16-63-65 triangle and a 33-56-65 triangle. However, this does not count because 65 is not a prime number.