A number Doubles When Last Digit Moves To The First Digit: Fermats Little theorem usage. My addition to the solution from here https://www.youtube.com/watch?v=1lHDCAIsyb8
goes whith usage of Fermats little theorem, but i want ask, if it is used properly there, because i have some doubts. But if it is correct, the solution is really short and elegant.
So the task is to find the least positive number, what doubles, if you move the least digit - the right digit  to the first - on very left position.
So let

*

*a be the first digit in [1..9]

*b the rest

*m - amount of digits after the first one

$$  \begin{cases}  x = 10 b + a \\  
2 x = a *10^m + b\end{cases}  \\ 
20b + 2a = a *10^m  + b \\  
b = \frac{2a*(5 * 10^{m-1}-1)  }{19  }$$
Since b is natural number, and a is a digit [1..9], the rest in brackets must be divisible to 19, or:
$$  5 * 10^{m-1} \text { mod }19 = 1 \\ $$
Understood now, what it looks like ?
Here, my part of the solution begins.
By the Fermat's little theorem:
$$ 10^{18} \text{ mod } 19 = 1 $$
And it is the smallest power, to get one as the modular rest.
So i rewrite it like that :
$$ 5 * 5^{m-1} * 2^{m-1} \text{ mod } 19 = 5^{18} *   2^{18}  \text{ mod } 19 = 1 $$
Here is the disputable step:
One could estimate m-1 = 18, m = 19 by counting "2" 's , is it actually a valide step?
The right solution on the video is m = 17 how to get it from here, i feel like it is possible somehow by the Fermat's little theorem.
Thanks for answers
 A: You have
$$\begin{equation}\begin{aligned}
5 \times 10^{m-1} & \equiv 1 \pmod{19} \\
(2 \times 5) \times 10^{m-1} & \equiv 2 \pmod{19} \\
10^{m} & \equiv 2 \pmod{19} \\
10 \times 10^{m} & \equiv 2 \times 10 \pmod{19} \\
10^{m + 1} & \equiv 1 \pmod{19}
\end{aligned}\end{equation}\tag{1}\label{eq1A}$$
where I've used that $2 \times 10 \equiv 20 \equiv 1 \pmod{19}$ to get the last line. Now you can use from Fermat's little theorem that one solution is $m + 1 = 18 \implies m = 17$.
Note the smallest value of $m$ comes from the multiplicative order of $10$ modulo $19$. This value needs to divide into $19 - 1 = 18 = 2 \times 3 \times 3$. Thus, if it's anything smaller, then $m + 1$ would need to be a proper factor of $18$, i.e., $1$, $2$, $3$, $6$ or $9$. You can confirm that you get, modulo $19$, the values of $10$, $5$, $12$, $3$ and $18$, respectively, so the smallest value of $m$ is indeed $m = 17$.
A: In your last displayed line (after "I rewrite like this"), you had a $5$ on the Left Hand Side.
In fact, $$10^{17} = 2\mod 19, \cdots (\dagger)$$ and $$10^{16} = 4\mod 19, \cdots (\dagger\dagger)$$ so after multiplying by $5$, you do get that $m-1=16$.
Do you get what I mean?  I mean that $5 \times 10^{16} = 1 \mod 19$.
Fermat indeed helped shorten the calculation of $(\dagger\dagger)$.
