## Productive Moving Digits

1. What is the smallest number which is quadrupled when its last digit is moved to be its first? Find all such numbers less than one million.
2. What is the smallest number which is tripled when its first digit is moved to be its last? Find all such numbers less than one million.
3. What is the smallest number which becomes five times greater when its last digit is moved to be its first? Find all such numbers less than one million.

Source: Martin Gardner's Dr. Matrix, with original embellishments, Used as Ken's POTD 4/20/94.

Solutions were received from Denis Borris, Simon Brault, Robert T. McQuaid, Bill Chapp, Kirk Bresniker, Artura Pascalin, Philippe Fondanaiche, Larry Baum, and Carlos Rivera.

The solutions are:

```1. Quadruple:
102564 -> 410256
128205 -> 512820
153846 -> 615384
179487 -> 717948
205128 -> 820512
230769 -> 923076

2. Triple:
142857 -> 428571
285714 -> 857142

3. Quintupled:
142857 -> 714285
```
Robert McQuaid sent the following algebraic analysis:
```For the first problem, call the initial part of the number
A and the final digit B, the two decimal numbers have
patterns AAAAB x 4 = BAAAA, where the number of A digits
may be anything up to 5.  In conventional algebra, this
is:  4*(10*A + B) = B*(10^k+A)
or:  B*(10^k-4) = 39*a

This produces a series of equations
2*B = 13*A      A of 1 digit
32*B = 13*A      A of 2 digits
332*B = 13*A      A of 3 digits
3332*B = 13*A      A of 4 digits
33332*B = 13*A      A of 5 digits

Either B must be 13, impossible in all cases, or the
coefficient of B must be divisible by 13.  The only
instance of this is the last one, leading to
solutions:  102564 x 4 = 410256
128205 x 4 = 512820
153846 x 4 = 615384
179487 x 4 = 717948
205128 x 4 = 820512
230769 x 4 = 923076

Similar considerations lead to solutions for the other two problems.
```
Bill Chapp sent the following AWK script he used to find the solutions. By expanding the script slightly, he showed that there are no other multiples (2-9) less than 1 million which can be found by moving the first or last digit to the other end of the number. Only the examples above can be found.
```BEGIN {
MULT=4;
for(i=1;i<10^6;i++) {
N=sprintf("%d",i);
M=substr(N,length(N),1) substr(N,1,length(N)-1);
if(M == MULT*N) printf("%d -> %d\n",N,M);
}
}
```

Philippe Fondanaiche's analysis:
```Question n°1
Let assume that the expected number N has n digits and is of the form:
N = 10 * A + B with B< 10 and A with n-1 digits
We have the relation  10^(n-1) * B + A = 4 * [ 10 * A + B ]
==> [ 10^(n-1) - 4 ] * B  = 39 * A = 3 * 13 * A
As B<10 , 10^(n-1) - 4 = 9999...96 is divisible by 13 . Moreover 9999...96 or
B are divisible by 3.
The smallest value of n is 6. Indeed 99 996 = 3 * 13 * 2 564
Then A = 2 564 * B
As A has 5 digits,the smallest expected number N is got for B = 4
Therefore N = 102 564 and 410 256 = 4 * 102 564

Question n°2
Let N = 10^(n-1) * A + B with A<10 and B with n-1 digits
We have 10 * B + A = 3 * [ 10^(n-1) * A + B ]
That means 7 * B = [ 3*10^(n-1) - 1 ] * A = 29999..99 * A
299....99 is divisible by 7
As 299 999 = 7 * 42 857,the smallest value of n is again 6.
Then B = 42 857 * A
As B has 5 digits, the smallest required number N is obtained for A = 1
Therefore N = 142 857 and 428 571 = 3 * 142 857
It's worth mentioning that another solution is got by permuting the digits of
the above number N,
that is to say N = 285 714 and 857 142 = 3 * 285 714

Question n°3
Same way of reasoning as in the question n°1.
We have the equation : [ 10^(n-1) - 5 ] * B = 9999...995* B = 49 * A
Here again, as 99 995 = 7 * 14 285, the smallest number N is got for n = 6 and
B = 7
So A = 14 285 and N = 142 857 with 714 285 = 5 * 142 857.
We find again the remarkable number of the previous question.
```
PS A generalization can be made in order to produce such cyclic numbers with different coefficients 2,3,4,....9. Chritopher Todd Igoe has issued in september 1995 a very interesting article on this topic and has found a procedure which allows to easily calculate these numbers (http://www.math.harvard.edu/~hmb/issue2.2/cyclic/cyclic.html). Here is the list of the smallest cyclic numbers that I have got for m=2,3,4,5...9 and corresponding to the questions n°1 and 3.
```
m   number       number N
of digits
2   18           105 263 157 894 736 842
3   28           1 034 482 758 620 689 655 172 413 793
4    6           102 564
5    6           142 857
6    58          1 016 949 152 542 372 881 355 932 203 389 830 508 474 576 271 186 440 677 966
7    22          1 014 492 753 623 188 405 797
8    13          1 012 658 227 848
9    44          10 112 359 550 561 797 752 808 988 764 044 943 820 224 719
```

Mail to Ken