Find all positive integers $x$ and $y$ for which $\frac{1}{x} + \frac{1}{y} = \frac{1}{p}.$

Once you get to $(x-p)(y-p)=p^2$ you use unique factorisation of integer to state that either $x-p=y-p=p$ leading to $x=y=2p$ or $x-p=p^2$ and $y-p=1$ leading to $x=p^2+p$ and $y=p+1$

The case $x-p=-p^2$ and $y-p=-1$ is to be excluded because $x$ and $y$ are assumed to be positive integers


$$p(x+y)=xy$$

$$p^2=xy-px-py+p^2$$

$$p^2=(x-p)(y-p)$$

Once you reach this form, we can consider a few cases:

Case $1$: $x-p = p$, $y-p=p$. That is $x=2p$ and $y=2p$.

Case $2$: $x-p=-p$, $y-p=-p$, which means $x=0$ which is not what we want.

Case $3$: $x-p=p^2$, $y-p=1$. $x=p(p+1)$, $y=p+1$.

Case $4$: $x-p=1$, $y-p=p^2$. Similar as case $3$.

Case $5$: $x-p=-p^2$, of which $x <0$, which is not what we want.

Similarly if $y-p=-p^2$.