TITLE: Smallest $n$-digit number $x$ with cyclic permutations multiples of $1989$
QUESTION [8 upvotes]: Suppose $x=a_1...a_n$, where $a_1...a_n$ are the digits in decimal of $x$ and $x$ is a positive integer. We define $x_1=x$, $x_2=a_na_1...a_{n-1}$, and so on until $x_n=a_2...a_na_1$. Find the smallest $n$ such that each of $x_1,...,x_n$ are divisible by $1989$. Any zero digits are ignored when at the front of a number, e.g. $x_1 = 1240$ then $x_2 = 124$.
Defining $T_n = 11...(n 1's)$ and $S_n = \sum 10^{n-k}a_k $ it is clear to see that $1989k=T_nS_n$ is a necessary condition, which is useful for disproving small $n$. 
But doing this I found $n \geq 6$, and the arithmetic becomes very difficult to do with pen and paper.
I'm looking for a more algebraic way of solving this question. Can anyone help me?

REPLY [3 votes]: This problem can be solved surprisingly easily, building upon Steven Stadnicki's hint, as follows.
I write $a=a_1a_2\cdots a_{n-1}=\sum_{i=1}^{n-1}a_i10^{n-1-i}$ and $b=a_n$.
Then $x_1=10a+b$ and $x_2=10^{n-1}b+a$. These must both be divisible by all of $9,13$ and $17$. Consequently the number $10x_2-x_1=(10^n-1)b$ must similarly be divisible by all those three primes. As Steve explained, divisibility by nine is automatic. The key observation is that as $b$ is constrained to be in the range $(0)1,\ldots,9$ (we ignore zero for a moment) we can conclude that $10^n-1$ must be divisible by both $13$ and $17$.
The order of $10$ modulo $13$ is six (ten is a quadratic residue modulo thirteen), but modulo $17$ it has the full order $16$ (in other words ten is a primitive root modulo seventeen). The least common multiple of $6$ and $16$ is $48$, so we conclude that $n$ must be a multiple of $48$.
But, the above calculation shows that any 48-digit multiple of $1989$ actually has this property! Start with such an $x_1$. The calculation we already did shows that $10x_2-x_1$ is necessarily divisible by $1989$. Therefore so is $x_2$. Rinse. Repeat.
So to find the smallest such $x$ we need
$$
m=\left\lceil\frac{10^{47}}{1989}\right\rceil=
50276520864756158873805932629462041226747110,
$$
and the answer is
$$
x=1989m=100000000000000000000000000000000000000000001790=10^{47}+1790.
$$

The reason we were able to ignore the case $a_n=b=0$ when deriving the condition $48\mid n$ is that the number must have some non-zero digits. So we can simply rotate its digits cyclically to have a non-zero digit in the least significant position.

I did check with Mathematica that all the 48 cyclic shifts of this number are divisible $1989$ :-) It is not unthinkable to actually do this with pen & paper work. You see, most of those cyclic shifts are of the form $17901\cdot10^\ell$ and $17901=1989\cdot9.$