LoginSignup
0
0

More than 1 year has passed since last update.

ABC149 C - Next Prime を解いた

Posted at

abc149_1.png
abc149_2.png

素数判定ってなんだっけ?
過去の自分に聞いてみた。

ok なるほど。
以下で通った。

abc149c.py
X = int(input())

def judge(n):
    from math import floor
    for i in range(2,floor(n**0.5)+1):
        if n%i == 0:
            return False
    return True

for j in range(1000):
    if judge(X+j):
        print(X+j)
        exit()

0
0
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
0
0