# If $pqr(p+q+r)$ is a square and $p,q,r$ are primes, then what's the maximum value of $p+q+r$?

We have primes $p\leq q\leq r$ such that $pqr(p+q+r)$ is a perfect square. Find $\max(p+q+r)$.

The only thing I've noticed is that all three can be the same. Let's say $pqr(p+q+r)=a^2$. Then if $p=q=r$, $a^2=3a^4$ but $3$ is not a square.

I think we might be able to show that two of them have to be the same (start from $p<q<r$, show a contradiction) but I'm not sure how to account for this. There's other cases that I think need to be considered, like $p=q<r$, but I'm not sure how to approach them.

I know this came from some sort of Australian contest, but I'm not sure which one. Possibly the AMC?

If $p<q<r$, then let $a=pqrk$ where $k$ is some integer, we have $$p+q+r=pqrk^2$$ But $p+q+r<3r$ which says that $pqk^2<3$, forcing one of $p$ and $q$ be $1$, contradiction.
If $p=q$, then $p^2r(2p+r)=a^2$, this makes $a=prk$, so \begin{align*}2p+r&=rk^2\\2p&=r(k^2-1)\end{align*}
if $r=2$, then $p=k^2-1=(k+1)(k-1)$, this force $k-1=1$, which makes $p=3$, now $p+q+r=3+3+2=8$.
If $r$ is odd, then $k+1$ and $k-1$ will be both even, so $$p=2r\cdot\dfrac{k+1}2\cdot\dfrac{k-1}2$$ Either $r=1$ or $r>1$ will lead to contradiction. Hence maximum value of $p+q+r$ is $8$.