### 2019 Switzerland TST #4

Find the largest prime $p$ such that there exist positive integers $a,b$ satisfying$$p=\frac{b}{2}\sqrt{\frac{a-b}{a+b}}.$$

The answer is $\boxed{5}$.

Assume that $p$ is an odd prime. We see that the original equation is equivalent to

$$4p^2(a+b) = b^2(a-b) \implies b(b^2+4p^2) = a(b^2 - 4p^2) \implies \frac{8p^2b}{b^2-4p^2}=a-b$$Denote $a-b=l$, then

$$lb^2 -8p^2b-4p^2l=0.$$ Consider this as equation as quadratic equation respect to variable $b$. The discriminant of this equation is

$$64p^4+ 16p^2l^2 = 16p^2( 4p^2 + l^2).$$Since $b$ is a positive integer, the discriminant must be a perfect square, and $16p^2$ is already a square, which implies that $4p^2+l^2$ is a square. So,

$$4p^2+l^2 = m^2 \implies 4p^2 = (m - l)(m + l)$$Let $m - l = x$ and $m + l = y$. Note that $y-x=2l$ and $(x,y)= (1;4p^2); (2;2p);(4;p^2); (p;4p);( 2p;2p);(1;4p);(4;p^2)( 2;2p^2); (1;4p^2)$. This implies that $l=p-1$ or $l=p^2 - 1$. It easy to check that $l=p-1$ fails.

Note that:

$$4p^2 + (p^2 - 1)^2 = ( p^2 + 1)^2 = m^2$$Therefore:

$$b = \frac{8p^2 \pm4p (p^2+1)}{2(p^2-1)}=\frac{4p^2\pm 2p(p^2+1)}{(p^2 -1)}$$Note that:

$$b = \frac{ 4p^2+2p^3+2p}{p^2-1} = 2p+4 + \frac{4}{p-1}$$This gives us $p=5$ or $p=3$.

If $b = \frac{ 4p^2-2p^3-2p}{p^2-1}$, then $b$ is not positive integer, which is a contradiction to the problem statement.

We want the largest $p$, so we choose $5$. Then, we can easily check that $a,b$ are positive integers, namely $39,15$, as desired. $\square$