Problem:
Compute the smallest positive integer such that, no matter how you rearrange its digits (in base ten), the resulting number is a multiple of .
Problem:
Compute the smallest positive integer such that, no matter how you rearrange its digits (in base ten), the resulting number is a multiple of .
Solution:
First, the number must be a multiple of and . The first is easy to check and holds for all permutations. Note that when two adjacent digits and are swapped, the number changes by (we disregard sign), so must also be a multiple of for all digits and . In particular, this is sufficient, since a permutation can be represented as a series of transpositions.
This means that must be a multiple of for all digits and , so either all digits are equal or they are in , or . We find the minimum for each case separately.
We first provide the following useful fact: the first repunit (numbers ) that is a multiple of is . This is because , and is a generator modulo (of course, you can just compute the powers of by hand, and it will not take much longer).
If a number is a multiple of , then either or is a multiple of ; if it is , then it's clear that we need to make the sum a multiple of . If is a multiple of , then it is at least , then to make a multiple of , we need .
If the only digits are and , then we need at least nine sevens to make the digit sum a multiple of nine, which has more digits than .
If the only digits are and , then we can note that since and are both , these numbers are equivalent to the repunits modulo , so such numbers have at least six digits. The best such six-digit number with digits summing to a multiple of is , which is our new candidate.
If the only digits are and , then by analogous logic such numbers have at least six digits. But the smallest such number is , which is not better.
So our best answer is . It works.