Solution (source code)

= Solution

Here $N^2=441$, so the least power of two exceeding it is $Q=2^9=512$. The continued fraction is
$$
\frac{427}{512}=[0;1,5,42,2],
$$
whose convergents begin
$$
0,\quad1,\quad\frac56,\quad\frac{211}{253},\quad\frac{427}{512}.
$$
The only nontrivial convergent with denominator below $N=21$ is $5/6$, and indeed
$$
\left|\frac{427}{512}-\frac56\right|
=\frac1{1536}<\frac1{2\cdot21^2}.
$$
The uniqueness result therefore gives
$$
\boxed{r=6.}
$$
As a check, $10^6\equiv1\pmod{21}$, while $10^2\not\equiv1$ and $10^3\not\equiv1$, so the order is exactly six.

Solved by gpt-5.6-sol high.