<s>[INST] Determine all positive integers $n$ which have a divisor $d$ with the property that $dn+1$ is a divisor of $d^2 + n^2$ Determine all positive integers $n$ which have a divisor $d$ with the property that $dn+1$ is a divisor of $d^2 + n^2$.
So i formed the equation that $$\frac{n}{d} = \frac{d^2 + n^2}{dn + 1}$$
And ended with $n = d^3$ which I think is wrong
If I'm wrong can someone please show me the right way.
 [/INST] Write $n = cd$.
Then
\begin{align*}
1 + dn \mid d^2 + n^2
&\iff 1 + cd^2 \mid d^2 + c^2 d^2 \\
&\iff 1 + cd^2 \mid d^2 (1 + c^2) \\
&\iff 1 + cd^2 \mid 1 + c^2 \quad \quad \quad (\text{since } 1 + cd^2 \text{ and } d \text{ are relatively prime}) \\
&\iff 1 + cd^2 \mid 1 + c^2 - (1 + cd^2) = c^2 - cd^2 \\
&\iff 1 + cd^2 \mid c(c - d^2) \\
&\iff 1 + cd^2 \mid c - d^2. \quad \quad \quad (\text{since } 1 + cd^2 \text{ and } c \text{ are relatively prime}) \\
\end{align*}
Therefore, we restate the problem as follows:
find all positive integers $\boldsymbol{c,d}$ such that $\boldsymbol{1 + cd^2 \mid c - d^2}$.
There are three cases: $c - d^2 = 0$, $c - d^2 > 0$, and $c - d^2 < 0$.


*

*Case 1: $c - d^2 = 0$
Here we get that $n = cd = d^3$, which is indeed one possible solution.

*Case 2: $c - d^2 > 0$.
In this case, $c - d^2$ is a positive multiple of $1 + cd^2$, so
$1 + cd^2 \le c - d^2$, so $cd^2 - c + d^2 - 1 \le -2$,
so $(c + 1)(d^2 - 1) \le -2$.
But this is a contradiction, since $c+1$ and $d^2-1$ are nonnegative.

*Case 3: $c - d^2 < 0$.
In this case, $d^2 - c$ is a positive multiple of $1 + cd^2$, so $1 + cd^2 \le d^2 - c$, so $cd^2 - d^2 + c - 1 \le -2$,
so $(c - 1)(d^2 + 1) \le -2$.
But this is a contradiction, since $c+1$ and $d^2-1$ are nonnegative.
Therefore, the only solution is $n = d^3$.
</s>