Initially, there is a positive integer $N$ on the blackboard. We repeatedly replace the number according to the following rules:

- replace the number on the board with a positive multiple of itself,
- replace the number with a number having the same digits in a different order. (It is allowed for the new number to start with one or more zeros, which are then omitted.)

Determine for which values of $N$ it is possible to get 1 after a series of moves.
An example of valid moves is $5 \rightarrow 20 \rightarrow 140 \rightarrow 041=41$.
Answer: this is possible if and only if $N \not \equiv 0 \bmod 3$. Indeed, if 3 is a divisor of $N$, then this remains so after both steps: every multiple of $N$ is divisible by 3, and swapping the digits does not change the sum of the digits.

Now assume that $N \not \equiv 0 \bmod 3$. We will first show that we can replace $N$ with a number that has only ones as digits. Then we will show that such a number can be replaced by 1.

By multiplying $N$ by 10, we can add zeros, and by swapping the digits, we can remove zeros. To replace $N$ with a number that has only ones as digits, we first multiply $N$ by 2 a number of times until the first digit is equal to 1. By then placing the 1 in the last position, we get a number that is relatively prime to 10. By Euler-Fermat, for $n=\varphi(N)$, we have that $10^{k n} \equiv 1^{k} \equiv 1 \bmod N$ for all $k$. This implies that $10^{n}+10^{2 n}+\ldots+10^{N n} \equiv 0 \bmod N$. This is thus a multiple of $N$, and by removing the zeros, we get a number with exactly $N \not \equiv 0 \bmod 3$ ones.

For step 2, we write $A_{n}$ for the number with $n$ digits all equal to 1. Now we observe that $10^{n}=9 \cdot A_{n}+1$, so $10^{n} \equiv 1 \bmod A_{n}$. This means that

$$
10^{10 n}+10^{9 n}+\ldots+10^{n}+A_{n}-10 \equiv 1+1+\ldots+1+A_{n}-10=A_{n} \bmod A_{n}
$$

Thus, the number on the left is a multiple of $A_{n}$, so we can obtain it from $A_{n}$ with step 1. It has 10 extra ones (in positions $10 n, 9 n$, etc., counting from the right, starting from the zeroth digit) and one 1 less (in the tens place). By applying step 2, we rewrite this to $A_{n+9}$. By repeating this step, we can obtain all $A_{m}$ with $m$ in the arithmetic sequence $n+9 k$, with $3 \nmid n$ and $k \geq 0$.

Now consider the set of powers of two modulo 9. This is the repeating sequence $1,2,4,8,7,5,1, \ldots$ In particular, every residue class not equal to $0,3,6$ occurs infinitely often in this sequence. This means that there is a power of two greater than $n$ with the same residue as $n$ modulo 9. This power of two is thus in the arithmetic sequence: there are $k$ and $\ell$ such that $n+9 k=2^{\ell}$.

Finally, we claim that we can make steps from $A_{2 n}$ to $A_{n}$. For this, we look for a power of two whose digits can be grouped into two equal-sized groups (plus or minus 1 for an odd number of digits) with the same sum. We find this with $2^{13}=8192$. With this, we come to the following steps from $A_{2}$ to $A_{1}$:

$$
11 \rightarrow 11 \cdot 118=1298 \rightarrow 8192=2^{13} \rightarrow 10^{13} \rightarrow 1
$$

If we group the ones of $A_{2 n}$ into pairs with enough zeros in between and apply these steps simultaneously to each group, then this also gives a process from $A_{2 n}$ to $A_{n}$. If we repeatedly apply this to $A_{2^{\ell}}$, we eventually end up at $A_{1}$.

Remark. Instead of $A_{N}$, we can also make the smaller number $A_{S}$ with $S$ the sum of the digits of $N$ with a bit more work. Indeed, assume that the $m^{\text {th }}$ digit of $N$ is greater than 1 (counting from the right, starting from the zeroth digit). Now choose $k$ such that $k n+m$ is greater than the number of digits of $N$ with $n=\varphi(N)$. Then $10^{k n+m}-10^{m}+N$ is a multiple of $N$ where the $m^{\text {th }}$ digit is one less, and we have one additional digit 1 with some zeros. By removing the zeros and repeating this step, we get a number that consists only of ones. Since we started with $N \not \equiv 0 \bmod 3$, the number of ones is not divisible by 3.