LoginSignup
1
1

More than 5 years have passed since last update.

Project Euler 52「置換倍数」

Posted at

たまには「これは問の性質上n桁~m桁の範囲のみチェックすればよい(キリッ」とか言いたいけど思いつかないので右ストレートでぶっ飛ばす、まっすぐ行ってぶっ飛ばす。

Problem 52 「置換倍数」

125874を2倍すると251748となる. これは元の数125874と順番は違うが同じ数を含む.
2x, 3x, 4x, 5x, 6x が x と同じ数を含むような最小の正整数 x を求めよ.

def hoge(num):
    f = lambda n: sorted(str(n))
    n = 1
    while not all( f(n) == f(n*i) for i in range(2, num+1) ):
        n += 1
    return n

print(hoge(6))
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1