Is there any formula to calculate the number of different Pythagorean triangle with a hypotenuse length $n$, using its prime decomposition?

Lets define $N(n)$ to be the number of different Pythagorean triangles with hypotenuse length equal to $n$.

One would see that for prime number $p$, where $p=2$ or $p\equiv 3 \pmod 4$, $N(p)=0$ also $N(p^k)=0$.

e.g. $N(2)=N(4)=N(8)=N(16)=0$

But for prime number $p$, where $p\equiv 1 \pmod 4$, $N(p)=1$ and $N(p^k)=k$.

e.g. $N(5)=N(13)=N(17)=1$ and $N(25)=2$ and $N(125)=3$

If $n=p^kq_1^{a_1}\dots q_r^{a_r}$, where $p$ be a prime of the form $4k+1$ and $q_i$'s be primes of the form $4k+3$ or be equal to $2$, then $N(n)=k$.

e.g. $N(14000)=N(5^3\times 2^4 \times 7)=3$

And also, If $n=p_1p_2q_1^{a_1}\dots q_r^{a_r}$, where $p_1$ and $p_2$ be primes of the form $4k+1$ and $q_i$'s be primes of the form $4k+3$ or be equal to $2$, then $N(n)=4$.

e.g. $N(65)=N(85)=4$

The question is:

Is there any formula to calculate $N(n)$, where $n=p_1^{a_1}\dots p_r^{a_r}$, by means of $N(p_1)$, … , $N(p_r)$?

A more general question is to compute $r_2(n)$, the number of ways an integer $n$ can be written as the sum of two squares (not ignoring order, and including negative numbers and $0$; this makes the answer nicer). The answer is classical and due to Jacobi: it turns out that

$$r_2(n) = 4 \left( d_1(n) - d_3(n) \right)$$

where $d_1(n)$ is the number of divisors of $n$ congruent to $1 \bmod 4$ and $d_3(n)$ is the number of divisors of $n$ congruent to $3 \bmod 4$. From here it's not much harder to ignore $0$, negative numbers, and order, but it makes the answer a bit less nice.

So the answer is something like $N(n)=\frac12[(2a_1+1)\dots(2a_r+1)-1]$ but just in case $n=p_1^{a_1}\cdots p_r^{a_r}$, where $p_i$'s are prime and $p_i\equiv 1 \pmod 4$, for $i=1,\dots,r$.

• can you show me... by examples? Commented Jun 10, 2016 at 2:02
• did you follow the link? It isn't easy, but the question isn't. If you have a further question please ask. Commented Jun 10, 2016 at 2:18
• yes... and thank you... Commented Jun 10, 2016 at 3:07

There are $$\space2^{x-1}\space$$ primitive triples for every valid hypotenuse value $$\space C \space$$ where $$\space x \space$$ is the number of distinct prime factors of $$\space C.\space$$

To find the one or more Pythagorean triples, if they exist, having the same hypotenuse, we solve the C-function of Euclid's formula for $$\space n \space$$ and we get

$${C=m^2+n^2\implies n=\sqrt{C-m^2} \quad \text{where}\quad \biggl\lfloor\sqrt{\frac{C}{2}}\biggr\rfloor \le m < \big\lfloor\sqrt{C}}\big\rfloor$$

Example: $$C=1105\implies \biggl\lfloor\sqrt{\frac{1105}{2}}\biggr\rfloor=23 \le m < \big\lfloor\sqrt{1105}\big\rfloor=33\quad \\ \text{and we find} \quad m\in\big\{24,31,32,33\big\} \implies n\in\big\{23,12,9,4\big\}\\$$

$$F(24,23)=(47,1104,1105)\quad F(31,12)=(817,744,1105)\\$$ $$F(32,9)=(943,576,1105)\quad F(33,4)=(1073,264,1105)\\$$

If we use the divisors of $$1105$$, we predict there are $$\space 2^{3-1}=4 \space$$ triples with $$\space C=1105\space$$ and this agrees with observation.