Permuted multiples

It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.

Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.


Idea

For $ x $, $ i * x, 2 \le i \le bound $ contain the same digits.

As $ bound * x $ cantains the same digits as $ 2 * x $, so they cantain same number of digits. As to say, if $ 2 * x $ is two-digit number, then $ bound * x $ is also two-digit number, so $ x \lt \frac{100}{bound}$


In [1]:
import sys, os; sys.path.append(os.path.abspath('..'))
from timer import timethis
In [2]:
@timethis
def solve(times):
    p = 1
    while True:
        for x in range(pow(10, p)+1, pow(10, p+1) // times + 1):
            if len(set([tuple(sorted(str(i * x))) for i in range(2, times+1)])) == 1:
                return x
        p += 1
In [3]:
solve(6)
Run for 0.375 seconds
Out[3]:
142857