How many values of $x$ are there such that $\sqrt{x(x+p)}$ is a positive integer for some $p$?

How many values of x are there such that there exists positive integer solutions for S, such that $S=\sqrt{x(x+p)}$ where $x$ is an integer and $p$ is a prime number $>2$?

This is a problem I made and will submit to brilliant.org, but before I do that I want some advice and your viewpoints.


Here is my proof: First we can say that since (p>2), it will always be odd since it a prime number.

In order to have (S) as positive we must have (x) as a perfect square. This also implies that (x+p) should also be a perfect square.

(Proof): Suppose, let us assume that (x) is not a perfect square. It implies, that (x+p) also cannot be a perfect square.

(CASE 1:) When (x) is an even number(not a perfect square), we have ((x+p)) as odd. This implies that we will always remain with the irrational number (\sqrt{2}), since (x) will have an odd power of (2) as it is not a perfect square and (x+p) is odd. (S) thus cannot be a positive integer.

(CASE 2:) Similarly, when (x) is odd, (x+p) is even: When (x+p) is not a perfect square then we can easily conclude that we will never find a positive solution for (S) since (x) and (x+p) are in opposite parity and both are imperfect squares.

Thus we reach a contradiction.

Therefore we must have (x=N^2) and (x+p=Y^2) where (N) and (Y) are integers other than (0).(Since we already considered the cases with 0).

Now, $Y^2-N^2=p$ $\Rightarrow (Y+N)(Y-N)=p$

Thus, it follows that (Y+N) and (Y-N) are factors of (p) thus they can either be equal to (1) or (p).

On solving we get $Y=\frac{p+1}{2}$ and $N=\frac{1-p}{2}$ or $N=\frac{p-1}{2}$ depending upon what we take (Y+N) and (Y-N) as, and (N) and (Y) can easily be verified to be integers. Thus we can conclude that, there exists a solution for which (x) and (x+p) are perfect squares. There is another solution when $x=-N^2$ and $x+p=-Y^2$.

So there are $2$ solutions in total.


It it valid to state that whenever $x$ is a multiple of $p$ there is no solution. Next, whenever $x$ is not a multiple of $p$ $gcd(x,x+p)=1$.

As such, it follows that if $x$ and/or $x+p$ are imperfect squares, then there exists no solutions.

So,

$x=N^2$

$x+p=Y^2$