<s>[INST] Prime number and square problem How many pairs of natural numbers, not bigger than 100, are such that difference between that pair is a prime number, and their product is a square of a natural number.
My attempt: I tried writing relationship such as $x-y=p$ and $xy=n^2$ but I can't seem to find any pattern to enumerate it.  
 [/INST] If $x - y$ is prime, then there can be at most one number that divides both $x$ and $y$, and it has to be that prime. Suppose the prime $p$ divides both $x, y$. Thus we can write $x = np$, and $y = (n-1)p$. Then we would have that $n(n-1)p^2$ is a square, hence so is $n(n-1)$. But $n, n-1$ are coprime, so this would mean that both $n, n-1$ are squares. This is impossible, so $p$ does not divide $x$ or $y$. It follows that $x, y$ are coprime.
Because $xy$ is also a square, it follows that $x, y$ must be squares individually -- so write $x = a^2, y = b^2$. Now a square is a sum of odd numbers,
$$
a^2 = \sum_{k=1}^a 2k-1,
$$
so
$$
a^2 - b^2 = \sum_{k=b+1}^a 2k-1.
$$
But we run into a restriction: if we have a sequence of odd numbers of more than one term, say $5, 7, 9$ or $25, 27$, then they are a multiple of their average. The first sum equals $3 \times 7$ and the second one $2 \times 26$. Thus we must have that the sum consists of at most one term, and we have $a = b+1$, and the sum is prime if and only if $2a-1$ is prime.
In the end your numbers are the $x, y$ such that $x = \left(\frac{p+1}{2}\right)^2$ and $y = \left(\frac{p-1}{2}\right)^2$, where $p$ is an odd prime.
</s>