<s>[INST] Find $N$ with $N^2=10^4M+N$ I'm a high school student in France and I participated in a math olympiad, and there was a question which I found impossible to solve. Maybe they are here some people who can help me:

We take a number $N$ which can be written by numbers $a,b,c$ and $d$ in
  the same order.
so $N=a(10^3)+b(10^2)+c10+d$. And $M\in \mathbb{Z}$ with
  $N^2=M(10^4)+N$
Find $M$.

 [/INST] $$10^4M=N^2-N=N(N-1)$$
Observe that $10^4$ divides $N(N-1)$ and $10^4>N\ge10^3$ as $N$ only has four digits. As their difference is 1, $N$ and $N-1$ are relatively prime to each other, meaning they don't have common divisors except $1$.
There are four cases
i) $10^4|N$, this cannot happen as $N$ is less than $10^4$.
ii) $2^4|N$ and $5^4|N-1$. Then, $N=k\cdot 5^4+1$ for some $k$. As $N$
has four digits, $2\le k\le 15$. $$5^4\equiv 1 \pmod{16}$$
So, $2^4=16|N$ implies $k=15, N=9376,M=8790$
iii) $5^4|N$ and $2^4|N-1$ Then, $N=k\cdot 5^4$ for some $k$. As $N$
has four digits, $2\le k\le 15$. $$5^4\equiv 1 \pmod{16}$$
So, $2^4=16|N-1$ implies $16|k-1$. However, no integer between $2$ and $15$ is equivelant to $1$ modulo $16$. Contradiction
iv) $10^4|N-1$, this cannot happen as $N-1$ is less than $10^4$.
</s>