B4. If you try to divide the number 19 by 5, it doesn't come out exactly. The number 5 fits 3 times into 19 and you have 4 left over as the remainder. There are two positive integers $n$ with the property: if you divide $n^{2}$ by $2 n+1$, there is a remainder of 1000.

Which two numbers are these?
4. 666 and 1999 We consider the cases $n$ even and $n$ odd separately.

First, assume that $n$ is even. We write $n=2 k$ with $k$ an integer. We then get: $n^{2}=4 k^{2}$ and $2 n+1=4 k+1$. When we divide $4 k^{2}$ by $4 k+1$, the result is $k-1$ and the remainder is $4 k^{2}-(k-1)(4 k+1)=3 k+1$. Since the remainder must be 1000, we find $3 k+1=1000$ and thus $k=333$. This gives the solution $n=2 \cdot 333=666$.

Now, assume that $n$ is odd. We can then write $n=2 k+1$ with $k$ an integer. We then get: $n^{2}=4 k^{2}+4 k+1$ and $2 n+1=4 k+3$. When we divide $4 k^{2}+4 k+1$ by $4 k+3$, the result is $k$ and the remainder is $4 k^{2}+4 k+1-k(4 k+3)=k+1$. Since the remainder must be 1000, we find $k+1=1000$ and thus $k=999$. This gives the solution $n=2 \cdot 999+1=1999$.