Project Euler 52
Project Euler 52
题目
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.
解决方案
直接枚举。可以发现,如果要满足上面的条件,那么\(x\)和\(6x\)的位数必须相同。
因此,对于一个\(n\)位数而言,只需要枚举这些\(n\)位数的前\(\dfrac{1}{6}\)的部分。
代码
1 | from itertools import count |