(IMO 1990/3) Find all integers $n \geq 1$ such that $n^{2}$ divides $2^{n}+1$.


Let's show that if $n$ divides $2^{n}+1$, then $n$ is a power of 3. By considering $p$ the smallest prime factor of $n$, considerations on the order of 2 modulo $p$ give $p=3$ as in the exercises from the course. Let's write $n=3^{k} u$ with $u$ not divisible by 3. The same reasoning shows that if $u>1$ then the smallest prime factor of $u$ is 3. We conclude that $n$ is a power of 3.

We apply LTE ($n$ is odd):

$$
v_{3}\left(2^{n}+1\right)=v_{3}(2+1)+v_{3}(n)=k+1
$$

But $v_{3}\left(n^{2}\right)=2 k$ and $n^{2}$ divides $2^{n}+1$. We deduce that $2 k \leq k+1$, which gives $k=0$ or $k=1$. Note that this last result can also be demonstrated immediately by looking at the powers of 2 modulo 9. Conversely, $n=1$ and $n=3$ are indeed solutions.