Project Euler Problem 052


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.


It's a brute-force approach using python's data structures and functions to help.

from itertools import takewhile, count
if __name__ == '__main__':
    mult = 1
    for result in takewhile(lambda x: mult < 6, count(1)):
        orig_set = set(str(result))
        tmp_set = set(str(result*2))
        mult = 2
        while orig_set == tmp_set:
            mult += 1
            tmp_set = set(str(result*mult))
    print("The result is:", result)

The Python file is available for download here.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License