# 59 arithmetic/digits/divisible.p

Find the least number using 0-9 exactly once that is evenly divisible by each
of these digits.

arithmetic/digits/divisible.s

Since the sum of the digits is 45, any permutation of the digits gives a
multiple of 9. To get a multiple of both 2 and 5, the last digit must
be 0, and thus to get a multiple of 8 (and 4), the tens digit must be
even, and the hundreds digit must be odd if the tens digit is 2 or 6,
and even otherwise. The number will also be divisible by 6, since it is
divisible by 2 and 3, so 7 is all we need to check. First, we will look
for a number whose first five digits are 12345; now, 1234500000 has a
remainder of 6 when divided by 7, so we have to arrange the remaining
digits to get a remainder of 1. The possible arrangements, in
increasing order, are

78960, remainder 0
79680, remainder 6
87960, remainder 5
89760, remainder 6
97680, remainder 2
98760, remainder 4

That didn't work, so try numbers starting with 12346; this is impossible
because the tens digit must be 8, and the hundreds digit cannot be even.
Now try 12347, and 1234700000 has remainder 2. The last five digits can
be

58960, remainder 6
59680, remainder 5, so this works, and the number is

1234759680.

Continue to: