Solution to problem 52

This commit is contained in:
David Doblas Jiménez 2021-09-26 16:07:52 +02:00
parent c4c2ae138b
commit 086ee02a6b

36
src/Python/Problem052.py Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""
Created on 26 Sep 2021
@author: David Doblas Jiménez
@email: daviddoji@pm.me
Solution for problem 52 of Project Euler
https://projecteuler.net/problem=52
"""
from utils import timeit
@timeit("Problem 52")
def compute():
"""
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.
"""
for number in range(123456, 1_000_000):
if sorted(str(number)) \
== sorted(str(2*number)) \
== sorted(str(3*number)) \
== sorted(str(4*number)) \
== sorted(str(5*number)) == sorted(str(6*number)):
return number
if __name__ == "__main__":
print(f"Result for Problem 52: {compute()}")