<s>[INST] Find all positive integers $x$ such that $x(x+2021)$ is a perfect square I completed the square as to get $(x+1010.5)^2-102110.25 = k^2$ but I don't know where to go from here.
Please help, thank you
I then got $(2x+2021)^2-4084441=4k^2$ then $(2k-2x-2021)(2k+2x+2021)=43^2*47^2$
 [/INST] If the product of two relatively prime numbers is a perfect square, then both factors must themselves be perfect squares. So, let's consider that case first.
How many ways can $2021$ be expressed as a difference of two squares? The answer to that is $2$. Namely, $2021=1011^2-1010^2=45^2-2^2$. Hence, $x=2^2=4$ and $x=1010^2=1020100$ are the two solutions coprime to $2021$.
Next, suppose that $x=43n$ is divisible only by $43$ (but not by $47$), so $x+2021=43(n+47)$ must then also be divisible by $43$. Then, for $x(x+2021)$ to be a perfect square, both $n$ and $n+47$ must themselves be perfect squares, and since $47$ is prime, the only solution for $n$ is $n=23^2=529$, which leads to the solution $x=43 \cdot 529=22747$.
Likewise, suppose that $x=47n$ is divisible only by $47$ (but not by $43$), so $x+2021=47(n+43)$ must then also be divisible by $47$. Then, for $x(x+2021)$ to be a perfect square, both $n$ and $n+43$ must themselves be perfect squares, and since $43$ is prime, the only solution for $n$ is $n=21^2=441$, which leads to the solution $x=47 \cdot 441=20727$.
Finally, suppose that $x=2021n$ is divisible by $2021$ (or equivalently, by both $43$ and $47$), so $x+2021=2021(n+1)$ must then also be divisible by $2021$. Then, for $x(x+2021)$ to be a perfect square, both $n$ and $n+1$ must themselves be perfect squares. The only solution for $n$ is $n=0$, but this leads to $x=0$, which is not a positive integer.
Hence, there are exactly $4$ solutions for $x$, namely $4, 20727, 22747,$ and $1020100$. Interestingly, the number of solutions for $x$ happens to itself be one of the solutions!
</s>