Problem:


Score: 300 points

Problem Statement

Find the minimum prime number greater than or equal to X.

Notes

A prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.

For example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.

Constraints

 2 \le X \le 10^5 

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X

Output

Print the minimum prime number greater than or equal to X.

Sample Input 1

20

Sample Output 1

23

The minimum prime number greater than or equal to 20 is 23.

Sample Input 2

2

Sample Output 2

2

X itself can be a prime number.

Sample Input 3

99992

Sample Output 3

100003



Sample input:
20


Sample output:
23

Submission status: Accepted

Solution code:
import random


def is_prime3(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q-1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q-1 and t & 1 == 0:
            return False
    return True


X = int(input())

while not is_prime3(X):
    X += 1

print(X)

Submission status: Accepted

Solution code:
import math
n=int(input())
flag=0
def sosuu(m):
    h=int(math.sqrt(m))
    for i in range(2,h+1):
        if m%i==0:
            return False
    return True

while flag==0:
    
    if sosuu(n):
        flag=1
        break
    n+=1
print(n)

Submission status: Accepted

Solution code:
import sys
x=int(input())
n = x
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
if x in primes:
    del primes[-1]
if x==2:
    print(2)
    sys.exit()
if x%2==0:
    x=x+1
while True:
    if all(x%i!=0 for i in primes):
        print(x)
        sys.exit()
    else:
        x=x+2

Submission status: Accepted

Solution code:
# abc149_c.py
import sys
import time
import unittest
from io import StringIO
import numpy as np


def resolve():
    X = int(input())
    x = np.array([i for i in range(2, -(-X // 2))])
    while 0 in (X % x):
        X += 1
    print(X)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def assertTLE(self, input):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin

    # def test_入力例_n(self):
    #     input = """val"""
    #     self.assertTLE(input)

    def setUp(self):
        self.startTime = time.time()

    def tearDown(self):
        t = time.time() - self.startTime
        print('%s: %.3f' % (self.id(), t), flush=True)

    def test_入力例_1(self):
        input = """20"""
        output = """23"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """99992"""
        output = """100003"""
        self.assertIO(input, output)


if __name__ == "__main__":
    if "IS_LOCAL" in locals():
        suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
        unittest.TextTestRunner(verbosity=0).run(suite)
    else:
        resolve()

Submission status: Accepted

Solution code:
# 素数かどうか判定する
import math
def is_prime(n):
    if n ==1: return True
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

x = int(input())

while not is_prime(x):
    x += 1
print(x)

Submission status: Accepted

Solution code:
x = int(input())
for i in range(x, 10 ** 6):
    L = list(range(2, i))
    flg = True
    for l in L:
        if i % l == 0:
            flg = False
            break
    if flg == True:
        print(i)
        break

Submission status: Accepted

Solution code:
x=int(input())


if x==2 or x==3:
    print(x)
else:
    i=x
    flag=True
    while i<=100003 and flag==True:
        flag=False
        for j in range(2,int(i**(1/2)//1+1)):
            if i%j==0:
                flag=True
                break
        i+=1
    print(i-1)

Submission status: Accepted

Solution code:
x = int(input())

if x == 2:
  print(x)
else:
  if x % 2 == 0:
    x += 1
  while True:
    sqrt = int(x ** 0.5)
    for i in range(3,sqrt+1,2):
      if x % i == 0:
        x += 2
        break
    else:
      print(x)
      break

Submission status: Accepted

Solution code:
def isPrime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True


n = int(input())

while True:
    if isPrime(n):
        print(n)
        break
    else:
        n += 1

Submission status: Accepted

Solution code:
X=int(input())
for i in range(X,10**6):
    res=0
    for j in range(2,i):
        if i%j==0:
            res=1
    if res==0:
        print(i)
        exit()

Submission status: Accepted

Solution code:
X=int(input())

i=int(X**0.5)
while i>=2:
    if X%i==0:
        X+=1
        i=int(X**0.5)
    else:
        i-=1

print(X)

Submission status: Accepted

Solution code:
def isprime(x):
    if x <= 1:
        return False
    else:
        i = 2
        while i*i <= x:
            if x % i == 0:
                return False
            i += 1
        return True

X = int(input())
while not(isprime(X)):
    X += 1
print(X)

Submission status: Accepted

Solution code:
X=int(input())

def isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, n):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
  # nまでの数で割り切れなかったら素数
  return True
  
while 1==1:
    if isPrime(X)==True:
        print(X)
        quit()
    X+=1

Submission status: Accepted

Solution code:
X = int(input())
cnt_0 = 0
cnt_1 = 0
while True:
  cnt_1 = 0
  ref_x = X + cnt_0
  ref_list = [i for i in range(2, ref_x)]
  for i in ref_list:
    if ref_x % i == 0:
      break
    else:
      cnt_1 += 1
  if cnt_1 == len(ref_list):
    print(ref_x)
    break
  cnt_0  += 1

Submission status: Accepted

Solution code:
import math
x=int(input())
if x<=2:
  print(x)
else:
  if x%2==0:
    x=x+1
  while True:
    for j in range(2,int(math.sqrt(x))+1):
      if x%j==0:
        break
    else:
      print(x)
      break
    x=x+2

Submission status: Accepted

Solution code:
def is_prime(n):
    if n <2:
        return False
    elif n ==2:
        return True
    else:
        for i in range(2,n):
            if n %i ==0:
                return False
        else:
            return True
x =int(input())

while is_prime(x) is False:
    x +=1
print(x)

Submission status: Accepted

Solution code:
import math
def generate_primes(num):
    primes = list(range(2, num + 1))
    i, p = 0, 1
    while p <= math.sqrt(num):
        if primes[i] != 0:
            p = primes[i]
            primes = [prime if prime % p != 0 else 0 for prime in primes]
            primes[i] = p
        i += 1
    return [p for p in primes if p != 0]
x = int(input())
for i, p in enumerate(generate_primes(100003)):
    if p >= x:
        print(p)
        break

Submission status: Accepted

Solution code:
x=int(input())

for num in range(x,10**6):
    ok = True
    for i in range(2,num):
        if num % i == 0:
            ok = False
    if ok:
        print(num)
        break

Submission status: Accepted

Solution code:
from bisect import bisect_left
def sieve_of_eratosthenes(N):
    numbers = [n & 1 for n in range(N + 1)]
    numbers[1] = 0
    primes = [2]
    p = 1
    while True:
        while not numbers[p]:
            p += 2
        if p * p > N:
            for i in range(p, N + 1, 2):
                if numbers[i]:
                    primes.append(i)
            return primes
        primes.append(p)
        for i in range(p, N + 1, p):
            numbers[i] = 0
primes = sieve_of_eratosthenes(10 ** 5 + 3)
print(primes[bisect_left(primes, int(input()))])

Submission status: Accepted

Solution code:
x = int(input())
 
 
def Prime(x):
    if x == 2:
        return 2
    if x % 2 == 0:
        return False
    else:
        sqrtx = x**(1/2)
        for i in range(3,int(sqrtx+1),2):
            if x % i == 0:
                return False
        return True
 
while True:
    if Prime(x):
        print(x)
        break
    x+=1

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    x = int(input())

    while True:
        for i in reversed(range(1, x)):
            if i == 1:
                print(x)
                exit()
            elif x % i == 0:
                break
        else:
            continue
        x += 1
        continue


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:

def solve():
    i = X
    while not prime(i):
        i += 1
#        print(i)
    print(i)

def prime(x):
    for i in range(2, int(x**0.5)+1):
        if (x % i == 0):
            return False
    return True


if __name__=="__main__":
    X = int(input())

    solve()

Submission status: Accepted

Solution code:
x = int(input())


def Prime(x):
    if x == 2:
        return 2
    if x % 2 == 0:
        return False
    else:
        sqrtx = x**(1/2)
        for i in range(3,int(sqrtx+1),2):
            if x % i == 0:
                return False
        return True

while True:
    if Prime(x):
        print(x)
        break
    x+=1

Submission status: Accepted

Solution code:
from math import sqrt
n=int(input())
def is_prime(n):
  if n<2:
    return False
  for k in range(2,int(sqrt(n))+1):
    if n%k==0:
      return False
  return True
while not is_prime(n):
  n+=1
print(n)

Submission status: Accepted

Solution code:
import math
x=int(input())
def prime(n):
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
for i in range(x,2**64):
    if prime(i)==True:
        print(i)
        break

Submission status: Accepted

Solution code:
X = int(input())
while True:
    for i in range(2, X//2):
        if X % i == 0:
            X += 1
            break
    else:
        break
print(X)

Submission status: Accepted

Solution code:
n=int(input())

import math

def is_prime(n):
  n_=math.floor(n**0.5)
  for i in range(2,n_):
    if n%i==0:
      return False
  return True

for k in range(n,200000):
  if is_prime(k)==True:
    print(k)
    break

Submission status: Accepted

Solution code:
# check
def is_prime(n):
    if n < 2:
        return False
    elif n == 2:
        return True
    else:
        for p in range(2, n):
            if n % p == 0:
                return False
        else:
            return True


# input
X = int(input())

while is_prime(X) is False:
    X += 1

print(X)

Submission status: Accepted

Solution code:
import sys
a=int(input())
i=a
if a==2:
  print(2)
  sys.exit()
while True:
  b=int(i**0.5)
  judge=False
  for j in range(2,b+2):
    if i%j==0:
      i+=1
      judge=True
      break
    else:
      continue
  if judge==False:
    print(i)
    sys.exit()

Submission status: Accepted

Solution code:
import math


def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

    X = int(input())

    for x in range(X, 10**6):
        if prime_judge(x):
            print(x)
            exit()


def prime_judge(n):
    for i in range(2, int(math.sqrt(n)+1)):
        if n % i == 0:
            return False
    return True


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
X=int(input())
ans=[0]*(2*X)
for x in range(X,2*X):
    cnt=0
    for i in range(2,x):
        if (x%i==0):
            cnt+=1
    if cnt==0:
        ans[x]=x
        break
print(max(ans))

Submission status: Accepted

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    X = int(input())
    while True:
        tmp = make_divisors(X)
        if len(tmp) == 2:
            break
        X += 1

    print(X)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math 
X  = int(input())
lis = [1]*(10**6+1)
lim = int(10**3)+1
for i in range(2,lim):
    if lis[i] == 1:
        for j in range(2,10**6+1):
            if i*j > 10**6:
                break
            else:
                lis[i*j] = 0

for i in range(X,len(lis)):
    if lis[i] == 1:
        print(i)
        break

Submission status: Accepted

Solution code:
x=int(input())
def hantei(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

if x==2:
    print(2)
    exit()

while True:
    if hantei(x)==1:
        print(x)
        break
    x+=1

Submission status: Accepted

Solution code:

import math 
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True # 全ての kで割り切れなかった場合
  
x = int(input())

while True:
  if is_prime(x):
    print(x)
    break
  x += 1

Submission status: Accepted

Solution code:
x = int(input())

ans = 0

def prime(x):
    y = x//2+1
    cnt = 0
    for i in range(2,y+1):
        if x%i==0:
            cnt += 1
            
    if x==2:
        return 2
    else:
        if cnt==0:
            return x
        else:
            return 0
            
while ans == 0:
    ans = prime(x)
    x += 1
    

print(ans)

Submission status: Accepted

Solution code:
def prime_check(a):
    checker = 2
    while checker * checker <= a:
        if a%checker == 0:
            return False
        checker +=1
    return True

X = int(input())

count = X
while not prime_check(count):
    count +=1
    
print(count)

Submission status: Accepted

Solution code:
x=int(input())
temp=2
while temp<x:
    if x%temp==0:
        x+=1
        temp=2
    else:
        temp+=1
print(x)

Submission status: Accepted

Solution code:
import math

x = int(input())
for t in range(x, 2*(10**5)):
    res = False
    for k in range(2, int(math.sqrt(t)) + 2):
        if t % k == 0:res = True
    if t == 2:res = False
    if(res):continue
    print(t)
    break

Submission status: Accepted

Solution code:
import sys

x = int(input())

while True:
    for i in range(2, x + 1):
        if x % i:
            continue
        else:
            if x == i:
                print(x)
                sys.exit()
            x += 1
            break

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import itertools
import math
x = ni()
def is_primes(n):
    primes = [1]*n
    primes[0] =0
    primes[1] =0
    for i in range(2,int(n**0.5)+1):
        if primes[i] ==1:
            for j in range(2*i,n,i):
                primes[j] = 0
    return primes
p = is_primes(10**7)
for i in range(10**7):
    if p[i] and i>=x:
        print(i)
        exit()

Submission status: Accepted

Solution code:
import bisect
#素数リスト
n = 10**5+10
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
  primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

x = int(input())
idx = bisect.bisect_left(primes, x)
print(primes[idx])

Submission status: Accepted

Solution code:
X = int(input())

def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

isPrime = makePrimeChecker(10**6)

while not isPrime[X]:
    X += 1

print(X)

Submission status: Accepted

Solution code:
import math
x=int(input())
yn=0
count=x-1
for i in range(x,x+100):
    count+=1
    yn=0
    for j in range(2,int(math.sqrt(count))+1):
        if count%j==0:
            yn=1
            break
        else:
            continue
    if yn==0:
        ans=count
        break
print(ans)

Submission status: Accepted

Solution code:
import math
import sys
sys.setrecursionlimit(100000)

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
  
X = int(input())

def findPrime(x):
  if is_prime(x):
    return x
  else:
    return findPrime(x+1)

print(findPrime(X))

Submission status: Accepted

Solution code:
x = int(input())

flag = True
while True:
    isPrime = True
    for i in range(2, x//2):
        if x%i == 0:
            x += 1
            isPrime = False
            break
            
    if isPrime:
        break
    
print(x)

Submission status: Accepted

Solution code:
"""
素数判定

エラトステネスの篩：
x^(1/2)以下の素数が既知のとき、x^(1/2)以上x以下の素数を決定するには、x以下の整数でx^(1/2)以下の素数の倍数を全て取り除けば（=篩えば）よい
"""
x = int(input())

while True:
    prime_flag = True
    for i in range(2, int(x**0.5+1)):
        if x%i == 0:
            prime_flag = False
            break
    if prime_flag:
        break
    else:
        x += 1
        
print(x)

Submission status: Accepted

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect
import itertools
import heapq


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(input):
    MAX = 110000
    X = int(input)
    eratosthenes = set(range(2, MAX+1))
    primes = []

    top = min(eratosthenes)
    while top <= math.sqrt(MAX):
        eratosthenes.remove(top)
        primes.append(top)

        multiple = top + top
        while multiple <= MAX:
            if multiple in eratosthenes:
                eratosthenes.remove(multiple)
            multiple += top
        top = min(eratosthenes)

    primes.extend(list(eratosthenes))
    primes.sort()

    for p in primes:
        if p >= X:
            return p


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(input())
    print(ret)

Submission status: Accepted

Solution code:
x = int(input())

while True:
    prime_flag = 1
    for i in range(2, int(x**0.5+1)):
        if x%i == 0:
            prime_flag *= 0
            break
    if not prime_flag:
        x += 1
        prime_flag = 1
    else:
        break
        
print(x)

Submission status: Accepted

Solution code:
import sys
import math

input = sys.stdin.readline

def check(x):
    for n in range(2, int(math.sqrt(x)) + 1):
            if x % n == 0:
                return False
    return True

def main():
    ans = 0
    x = int(input())
    while check(x) == False:
        x += 1
    print(x)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x=int(input())
i=1
s=set([])
while(i<int(x**0.5)):
    i+=1
    mkr=0
    for j in s:
        if i%j==0:
            mkr=1
            break
    if mkr==0:
        s|={i}
i=x-1
while(1):
    i+=1
    mkr=0
    for j in s:
        if i%j==0:
            mkr=1
            break
    if mkr==0:
        print(i)
        break

Submission status: Accepted

Solution code:
from math import *

def isprime(n):
  if n<10: return n in (2,3,5,7)
  for i in range(2,int(sqrt(n)+1)):
    if n%i==0:
      return False
  return True

x = int(input())
for d in range(x, x+300):
  if isprime(d):
    print(d)
    break

Submission status: Accepted

Solution code:
from math import *

def isprime(n):
	if n<10:
		return n in (2,3,5,7)
	for i in range(2,int(sqrt(n)+1)):
		if n%i==0:
			return False
	return True
 
x = int(input())
for d in range(x,x+300):
	if isprime(d):
		print(d)
		break

Submission status: Accepted

Solution code:
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
x = int(input())
for i in range(x,x+10000):
    if len(factorize(i)) == 1:
        print(i)
        break

Submission status: Accepted

Solution code:
import math

x = int(input())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True


while True:
    if is_prime(x):
        print(x)
        exit()
    else:
        if x % 2 ==0:
            x += 1
        else:
            x += 2

Submission status: Accepted

Solution code:
x=int(input())

def isprime(n):
    if n==1:
        return False
    else:
        for i in range(2,int(n**0.5)+1):
            if n%i==0:
                return False
        return True
        
while True:
    if isprime(x):
        print(x)
        exit()
    else:
        x+=1

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
while ans == 0:
    count = 2
    flg = 0
    while x >= count and flg == 0:
        if x % count == 0:
            flg = 1
            if x == count:
                ans = x
        else:
            count += 1
    x += 1
print(ans)

Submission status: Accepted

Solution code:
X=int(input())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
  
while True:
  if is_prime(X):
    print(X)
    exit()
    
  X=X+1

Submission status: Accepted

Solution code:
import math
x=int(input())
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return n
for i in range(x,x+10000):
    tmp=is_prime(i)
    if tmp:
        print(tmp)
        exit()

Submission status: Accepted

Solution code:
X=int(input())
def sosuhantei(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

if X==2:
    print(2)
    exit()

while True:
    if sosuhantei(X)==1:
        print(X)
        break
    X+=1

Submission status: Accepted

Solution code:
import math
import random

def fermat(k):
    if k % 2 == 0 and k != 2:
      return False
            
    if pow(2, k-1, k) == 1:
      return True
    else:
      return False
def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True    
def using_sqrt(k):  
    factor = 0
        
    # 2以外の偶数は素数ではないので無視する
    if k % 2 == 0 and k != 2:
        return False
        
    # 繰り返しの上限を対象の平方根にする
    for divisor in range(2, math.floor(math.sqrt(k))+1):
        if k % divisor == 0:
            factor += 1
                
    if factor == 0:
        return True
    else:
        return False
            
 
  
n=int(input())
while True:
  if fermat(n):
    if using_sqrt(n):
      print(n)
      break
  if is_prime(n):
    if using_sqrt(n):
      print(n)
      break    
  n+=1

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 14:38:46 2020

@author: shinba
"""

x = int(input())

while True:
    for i in range(2,int(x**(0.5))):
        if x % i == 0:
            x += 1
            break
    else:
        break

print(x)

Submission status: Accepted

Solution code:
x=int(input())

def sosu(x):
    
    if x==2:
        return True
    
    else:
        for i in range(2,x-1):
            if x%i==0:
                return False
        
        return True
        
        
for j in range(x,10**6):
    if sosu(j):
        print(j)
        break

Submission status: Accepted

Solution code:
import math
X = int(input())

def isSosu(n) :
    dest = int(math.sqrt(n))

    if n == 2 :
        return True

    for i in range(2, dest+2) :
        if n % i == 0 :
            return False

    return True


for j in range(X, 10**6) :
    if isSosu(j) :
        print(j)
        break

Submission status: Accepted

Solution code:
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.floor(x)
  for i in range(X,(key+1)**2):
    l.append(i)
    
for n in range(2,key+1):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Submission status: Accepted

Solution code:
x = int(input())
def is_prime(x):
    if x <= 1:
        return False
    for i in range(2, int(x**0.5)+1):
        if x % i == 0:
            return False
    return True

while(not is_prime(x)):
    x += 1
print(x)

Submission status: Accepted

Solution code:
x = int(input())
while True:
    is_prime = True
    for i in range(2, x):
        if x % i == 0:
            is_prime = False
            break
    if is_prime:
        print(x)
        break
    x += 1

Submission status: Accepted

Solution code:
def is_prime(n):
    i = 2
    while i*i <= n:
        if n % i == 0:
            return False
        i += 1
    return True


x = int(input())
while not is_prime(x):
    x += 1
print(x)

Submission status: Accepted

Solution code:
# coding: utf-8
import math


def prime(X):
    if X == 1:
        return False
    
    for i in range(2, int(math.sqrt(X)) + 1):
        if X % i == 0:
            return False
    return True


X = int(input())
while prime(X) == False:
    X += 1
print(X)

Submission status: Accepted

Solution code:
x = int(input())
ans = x
flg = False
while not flg:
    li = []
    for i in range(1,(ans)//2+1):
        if ans % i == 0:
            li.append(1)
        else:
            li.append(0)
    if sum(li) == 1:
        flg = True
    else:
        flg = False
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
t=n
g=0
while g==0:
  b=0
  for i in range(n):
    if i!=0 and i!=1:
      a=t%i
      if a==0:
        b=1
  if b==0:
    print(t)
    exit()
  else:
    t+=1

Submission status: Accepted

Solution code:
import sys
x=int(input())
if x==2 or x==3:
    print(x)
    sys.exit()
while 1:
    i=2
    c=False
    while i*i<=x:
        if x%i==0:
            c=True
            break
        i+=1
    if c:
        x+=1
        continue
    else:
        print(x)
        break

Submission status: Accepted

Solution code:
x = int(input())


def is_prime(n):
    n_sqrt = n ** 0.5
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for num in range(3, int(n_sqrt), 2):
        if n == num:
            return True
        if n % num == 0:
            # 素数ではない
            return False
    return True


while not is_prime(x):
    x += 1

print(x)

Submission status: Accepted

Solution code:
def primelist(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
  
x = int(input())

list = primelist(x*2)
print(min([i for i in list if i>=x]))

Submission status: Accepted

Solution code:
X = int(input())
if X == 2:
    print(2)
    exit()
while True:
    N = int(X**0.5)
    for i in range(1,N):
        if X % (i+1) == 0:
            break
        else:
          if i == N - 1:
            print(X)
            exit()
    X += 1

Submission status: Accepted

Solution code:
import math
def is_prime(n):
  if n == 1:
    return False
  for p in range(2, int(math.sqrt(n))+1):
    if n%p == 0:
      return False
  return True
m = int(input())
while m > 0:
  if is_prime(m) == True:
    print(m)
    break
  m += 1

Submission status: Accepted

Solution code:
X = int(input())
def is_prime(n):
    if n <= 1:
        return False
    
    for i in range(2,int(n**0.5)+1):
        if n % i ==0:
            return False
    return True
while not is_prime(X):
        X+=1
print(X)

Submission status: Accepted

Solution code:
X = int(input())
def is_prime(n):
    if n <= 1:
        return False
    
    for i in range(2,int(n**0.5)+1):
        if n % i ==0:
            return False
    return True

for i in range(X,(X*2)+100,):
    if is_prime(i):
        print(i)
        break

Submission status: Accepted

Solution code:
X = int(input())
import math 
def get_prime(n):
    
    if n <=1:
        return []
    prime = [2]
    limit = int(math.sqrt(n))
    
    # 奇数のリストを作成
    data = [i+1 for i in range(2,n,2)]
    while limit > data[0]:
        prime.append(data[0])
        data = [j for j in data if j % data[0] !=0]
    return prime + data
for x in get_prime(2*X):
    if x >=X:
        print(x)
        break

Submission status: Accepted

Solution code:
import math
def is_sosu(n):
  for i in range(2, math.floor(math.sqrt(n))+1):
    if n % i == 0:
      return False
  return True

x = int(input())
for i in range(x, x*2):
  if is_sosu(i):
    print(i)
    exit()

Submission status: Accepted

Solution code:
x = int(input())

if x == 2:
    print(x)
    exit()

ans = x
if ans%2 == 0:
    ans += 1
while True:
    i = 3
    while i < x:
        if ans%i == 0:
            break
        i += 2
    else:
        print(ans)
        exit()
    ans += 2

Submission status: Accepted

Solution code:
x = int(input())

def is_prime(n):
  if n <= 1: return False
  for i in range(2, int(n**0.5)+1):
    if n % i == 0: return False
  return True

if not is_prime(x):
  while not is_prime(x):
    x += 1
print(x)

Submission status: Accepted

Solution code:
import bisect
x = int(input())

def get_prime(n):
  if n <= 1: return []
  limit = int(n**0.5)
  prime = [2]
  data = [i+1 for i in range(2,n,2)]
  while limit >= data[0]:
    prime.append(data[0])
    data = [j for j in data if j % data[0] != 0]
  return prime + data

l = get_prime(10**5+3)
i = bisect.bisect_right(l, x)
if l[i-1] == x: print(x)
else: print(l[i])

Submission status: Accepted

Solution code:
def is_prime(X):
    if X <= 1:
        return False
    else:
        for i in range(2, int(X**0.5) + 1):
            if X % i == 0:
                return False
        return True


X = int(input())
num = X

while True:
    if is_prime(num):
        print(num)
        exit()
    else:
        num += 1

Submission status: Accepted

Solution code:
'''
参考
https://qiita.com/srtk86/items/874639e361917e5016d4

整数Nが素数である=√N以下のすべての数で割り切れない
'''
import math

def is_prime(n):
    if n == 1:
        return False
    
    for m in range(2, int(math.sqrt(n)+1)):
        if n % m == 0:
            return False
    
    return True

X = int(input())

while True:
    if is_prime(X) == True:
        break
    X += 1

print(X)

Submission status: Accepted

Solution code:
X = int(input())
def is_prime(num):
    if(num<=1):
        return False
    for i in range(2,num):
        if(num%i==0):
            return False
    return True

while True:
    if(is_prime(X)):
        print(X)
        break
    else:
        X+=1