嵇爾的吐槽

#没事画轮子的嵇尔不定期的(W)碎(E)碎(B)念(B)和(L)吐(O)槽(G)

Problem 52 Permuted multiples 2016-11-17 13:20:00

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. result = 1

while True:
    result_str = list(str(result))
    result_str.sort()
    flag = True
    for p in reversed(range(2, 7)):
        target = p * result
        target_str = list(str(target))
        target_str.sort()
        if not target_str == result_str:
            flag = False
            break
    if flag:
        print result
        break
    result += 1

感觉很简单的样子

评论共