# 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? – Omid Ghayour Jun 10 '16 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. – Ross Millikan Jun 10 '16 at 2:18
• yes... and thank you... – Omid Ghayour Jun 10 '16 at 3:07

This is not a direct calculation but it does answer the question of how to find one or more Pythagorean triples, if they exist, having the same hypotenuse. If we solve the C-function of Euclid's formula for $$n$$, we get

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

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

$$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 find there is one triple each for the prime factors $$C\in\{5,13,17\}$$, and two more triples each for the composite divisors $$C\in\{65,85,221\}$$. If we multiply these divisor-triples by their $$1105$$ co-factors, we find a total of $$4+6=10$$ distinct triples were $$C=1105$$.