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: Time Limit Exceeded

Solution code:
x = int(input())
l = []
for i in range(2,x):
    key = "T"
    for j in l:
        if i % j == 0:
            key = "F"
            break
    if key == "T":
        l.append(i)
key = "F"
while key == "F":
    key1 = "T"
    for i in l:
        if x % i == 0:
            key1 = "F"
            break
    if key1 == "T":
        key = "T"
    x += 1
print(x-1)

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
l=[2]
t=3
while 1:
    for i in l:
        if t%i==0:
            break
    else:
        if t>=X:
            break
        l.append(t)
    t+=1
if X==2:
    t=2
print(t)

Submission status: Time Limit Exceeded

Solution code:
#%%
import math

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
l = callIsPrime(10**6)

x = int(input())
for i in range(len(l)):
    if l[i] >= x:
        print(l[i])
        break

# %%

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

lst = get_sieve_of_eratosthenes(10**6+1)
x = I()
for i in lst:
    if x <= i:
        print(i)
        quit()

Submission status: Accepted

Solution code:
n = int(input())
count = 0

def prime(n):
    if n == 2:
        return True
    else:
        i = 2
        while i ** 2 <= n:
            if n % i == 0:
                return False
            i += 1
        return True
i = n
while not prime(i):
    i += 1
print(i)

Submission status: Accepted

Solution code:
X = int(input())
if X == 2:
  print(X)
while X > 2:
  if X % 2 == 0:
    # 偶数
    X += 1
  else:
    n = 3
    while n * n <= X:
      if X % n == 0:
        # 割り切れる
        X += 1
        break
      n += 1
    else:
      print(X)
      break

Submission status: Accepted

Solution code:
import math
X = int(input())
if X == 2:
    print(2)
else:
    is_end = False
    while not is_end:
        is_end = True
        for i in range(1, X // 2):
            if math.gcd(X, i) != 1:
                is_end = False
                X += 1
                break
    print(X)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def solve(x: int):
    for n in range(2, int(x ** 0.5) + 1):
        if x % n == 0:
            return False
    return True


def main():
    X = int(input())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import sqrt
x = int(input())

while True:
    f = 1
    s = int(sqrt(x))
    for i in range(2, s+1):
        if x % i == 0:
            f = 0
            break
    if f == 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

x = int(input())

for i in range(x, 10**5 + 4):
    if is_prime(i) == True:
        print(i)
        exit()

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

p=X
while not is_prime(p):
    p+=1

print(p)

Submission status: Accepted

Solution code:
import math

x=int(input())

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

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

print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(X: int):
    if X == 2:
        print(X)
        return
    n = X -1
    while True:
        n += 1
        if n % 2 == 0:
            continue
        f = True
        for i in range(3, (n//2)+1, 2):
            if n % i == 0:
                f = False
                break
        if f:
            print(n)
            break

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for i in range(x, 10000000):
    is_prime_bool = True
    for j in range(2, i - 1):
        if i % j == 0:
            is_prime_bool = False
            break
    if is_prime_bool:
        print(i)
        break

Submission status: Accepted

Solution code:
from math import sqrt
x = int(input())

while True:
    isP = True
    for i in range(2, int(sqrt(x))):
        if x % i == 0:
            isP = False
            break
    if isP:
        print (x)
        break
    x += 1

Submission status: Accepted

Solution code:
x = int( input() )

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

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

Submission status: Accepted

Solution code:
from bisect import bisect_left

n = int(input())
hurui = [True for _ in range(100010)]
prime_lst = []
for i in range(2, 100010):
  if not hurui[i]:
    continue
  prime_lst.append(i)
  for j in range(i * i, 100010, i):
    hurui[j] = False

pos = bisect_left(prime_lst, n)
print(prime_lst[pos])

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
if x == 2:
    ans = 2
elif x == 3:
    ans = 3
else:
    for i in range(x,100004):
        check = True
        root = int(i ** 0.5) + 1
        for j in range(2,root):
            if i % j == 0:
                check = False
                break
            else:
                continue
        if check:
            ans = i
            break
print(ans)

Submission status: Accepted

Solution code:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

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

Submission status: Accepted

Solution code:
# Original Submission At: https://atcoder.jp/contests/abc149/submissions/16823042
x= int(input())

def prime_check(num,count):
    while True:
        while num % count == 0:
            num = num + 1
            count = 2
        if num <= count**2:
            print(num)
            break
        else:
            count = count + 1

if x==2 :
    print (2)
else:
    prime_check(x,2)

Submission status: Accepted

Solution code:
# Original Submission At: https://atcoder.jp/contests/abc149/submissions/16823042
import sys
sys.setrecursionlimit(1000000)

x= int(input())

def prime_check(num,count):
    if (num % count) != 0:
        if num <= count**2:
            print(num)
        else:
            prime_check(num,count+1)
    else :
        prime_check(num+1,2)

if x==2 :
    print (2)
else:
    prime_check(x,2)

Submission status: Accepted

Solution code:
MAX=200000
def get_prime(x):
  is_prime = [True] * 200000
  for i in range(2,MAX):
    if is_prime[i] and i >= x:
      return i
    elif is_prime[i]:
      for j in range(2 * i, MAX, i):
        is_prime[j] = False

print(get_prime(int(input())))

Submission status: Accepted

Solution code:
primeornot=[True]*(10**5*2)
for i in range(2,10**5):
    if primeornot[i]==True:
        j=2*i
        while j<10**5*2:
            primeornot[j]=False
            j+=i
x=int(input())
for i in range(x,10**5*2):
    if primeornot[i]==True:
        print(i)
        break

Submission status: Accepted

Solution code:
x=int(input())
flag=1
prime=[]
num=2
while flag!=0:
    f=0
    for p in prime:
        if num%p==0:
            f=1
            break
    if f==0:
        prime.append(num)
        if x<=num:
            flag=0
    if flag==0:
        break
    else:
        num+=1
print(num)

Submission status: Accepted

Solution code:
X = int(input())

if X == 2:
    print(2)
    exit()
    
for i in range(X,2*X):
    for j in range(2,i):
        if i % j == 0:
            break
        if j == i-1:
            print(i)
            exit()

Submission status: Accepted

Solution code:
X = int(input())

def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

prime = get_sieve_of_eratosthenes_new(10**6)
for num in prime:
    if num >= X:
        print(num)
        break

Submission status: Accepted

Solution code:
x = int(input())
if x == 2:
    print(2)
    exit()
while True:
    flg = 0
    for i in range(2,int(x**0.5)+1):
        if x%i == 0:
            flg += 1
        if i == int(x**0.5) and flg == 0:
            print(x)
            exit()
    x += 1

Submission status: Accepted

Solution code:
X = int(input())

def prime_judge(N):
  K = 2
  ans = True
  while K*K <= N:
    if N%K == 0:
      ans = False
      break
    else:
      K += 1
  return ans

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())


while True:
  a = []
  for i in range(2,X):
    if X % i == 0:
      a.append(0)
      break
    else:
      a.append(1)
  
  if 0 in a:
    X += 1
  else:
    break

print(X)

Submission status: Accepted

Solution code:
x = int(input())

def isprime(s):
  if s>2 and s%2==0:
    return False
  else:
    flg = True
    for i in range(3, s//2+1, 2):
      if s%i == 0:
        flg = False
        break
    return flg

for i in range(x, 10**6):
  if isprime(i) == True:
    print(i)
    break

Submission status: Accepted

Solution code:
x = int(input())

def prime_check(n):
    f = 3
    while f * f <= n:
        if n % f == 0:
            return False
        else:
            f += 2
    else:
        return True

if x != 2:
    if x % 2 == 0:
        x += 1
    while 1:
        if prime_check(x) == True:
            print(x)
            break
        else:
            x += 2
else:
    print(2)

Submission status: Accepted

Solution code:
x = int(input())
n = int(x**0.5)

if x==2 or x==3:
    print(x)
else:
    while True:
        for i in range(2,n+1,1):
            if x%i==0:
                break
        else:
            print(x)
            break
        x += 1

Submission status: Accepted

Solution code:
X=int(input())

p=[True for _ in range(0,200000+1)]
p[0]=False
p[1]=False
for i in range(2,200000+1):
    if p[i]==False:
        continue
    for j in range(2,200000//i):
        p[i*j]=False

while p[X]==False:
    X+=1
print(X)

Submission status: Accepted

Solution code:
import math
X = int(input())
if X == 2:
    print(2)
else:
    is_find = False
    while not is_find:
        for i in range(2, X//2):
            is_find = True
            if math.gcd(X, i) != 1:
                is_find = False
                X += 1
                break
        rst = X
    print(rst)

Submission status: Accepted

Solution code:
# coding: utf-8
from math import sqrt

def main():
    X = int(input())

    for i in range(X, 100004):
        tmp = int(sqrt(i))
        flg = False
        for j in range(2, tmp + 1):
            if (i % j == 0):
                flg = True
                break
        if flg == False:
            ans = i
            break

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
X = int(input())
flag = 0
if X == 2 or X == 3:
    flag = 1
    print(X)
while flag == 0 :
    for i in range(2,int(X**0.5)+1):
        if X%i == 0:
            X += 1
            break
        else:
            if i == int(X**0.5):
                flag = 1
                print(X)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

ans = x
past = int(ans**0.5)
divisor = [i for i in range(1, past+1, 1) if x%i == 0]
while len(divisor) != 1:
    if ans%2 == 0:
        ans += 1
    else:
        ans += 2
    root = int(ans**0.5)
    divisor = [j for j in range(1, root+1, 1) if ans%j == 0]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
m=2*(10**5)
lis=[True for i in range(m)]
i=2
while i*i<=m:
    if lis[i]:
        for j in range(2*i,m,i): lis[j]=False
    i+=1
while True:
    if lis[x]:
        print(x)
        break
    x+=1

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x = int(input())
def f():
    for i in range(x, 10**10):
        c = 0
        for j in range(2, i):
            if i%j != 0:
                c += 1
                if c == i-2:
                    return i
            else:
                break
if x == 2:
    print(2)
else:
    print(f())

Submission status: Accepted

Solution code:
import sys
N = int(input())
if N == 2:
  print(2)
  sys.exit()
n = N-1
Flag = True
while Flag:
  n += 1
  for i in range(2,int(n**0.5)+1):
    if n%i == 0:
      break
    if i == int(n**0.5) and n%i != 0:
      Flag = False
  
print(n)

Submission status: Accepted

Solution code:
import math

def is_prime(x):
	for i in range(2, int(math.sqrt(x))):
		if x % i == 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())
flag=0

if X==2 or X==3:
	flag=1

while flag==0:
	for k in range(2,int(X**0.5)+1):
		if k==int(X**0.5) and X%k!=0:
			flag=1
		
		if k>2 and k%2==0:
			continue
		elif k>3 and k%3==0:
			continue
		elif X%k==0:
			break
	
	if flag==0:X=X+1	
		
print(X)

Submission status: Accepted

Solution code:
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
def is_prime(t):
    k = 2
    while k*k <= t:
        if t%k == 0:
            return False
        k+=1
    return True

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from itertools import chain
import numpy as np


def solve(X: int):
    if X <= 2:
        return 2
    flags = np.array([True for i in range(3, X + 100, 2)])
    for i in range(len(flags)):
        if flags[i]:
            prime = i * 2 + 3
            flags[i::prime] = False
            if prime >= X:
                return prime




def main():
    X = int(input())  # type: int
    answer = solve(X)
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from itertools import chain
import numpy as np


def solve(X: int):
    if X <= 2:
        return 2
    flags = np.array([True for i in range(3, X + 112, 2)])
    for i in range(len(flags)):
        if flags[i]:
            prime = i * 2 + 3
            flags[i::prime] = False
            if prime >= X:
                return prime




def main():
    X = int(input())  # type: int
    answer = solve(X)
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

def isPrime(n):
    if n < 2:
        return False
    else:
        divisors = []
        tem = []
        for p in range(1,math.ceil(n**(1/2)+1)):
            if n % p == 0:
                divisors.append(p)
        
        for divisor in divisors:
            tem.append(n//divisor)
        
        divisors = list(set(sorted(divisors + tem)))
        
        if len(divisors) == 2:
            return True
        else:
            #print(divisors)
            return False

X = int(input())

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

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    if X == 2:
        print(2)
        exit()
    if X % 2 == 0:
        X += 1
    while True:
        flag = True
        for i in range(3, X, 2):
            if X % i == 0:
                flag = False
                break
        if flag is True:
            print(X)
            break
        else:
            X += 2


if __name__ == '__main__':
    main()

Submission status: Accepted

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

while True:
  a = int(math.sqrt(x))
  for y in range(2,a+1):
    if x % y == 0:
      break
  else:
    ans = x
    break
  x += 1

  
print(ans)

Submission status: Accepted

Solution code:
import sys
import copy
X = int(input())
while True:
    b = False
    for i in range(2,X):
        if X%i == 0:
            b = True
            break

    if b == False:
        print(X)
        sys.exit(0)
    else:
        X+=1

Submission status: Accepted

Solution code:
n = int(input())
 
def p(x):
  if x == 2:
    return True
  for i in range(2,x//2):
    if x % i == 0:
      return False
  return True
 
for i in range(n,2*n):
  if p(i):
    print(i)
    break

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    X=I()
    
    #nまでの素数を列挙(n loglogn)
    n = 2*(10**6)

    #is_prime[i]にはi+1が素数か否かを示すboolが入る，[0]に1の素数判定がある．
    is_prime = [True]*(n+1)
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i

    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    
    for i in table:
        if i>=X:
            print(i)
            exit()

main()

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

def main():
    x = int(input())

    for i in range(x,100004):
        if is_prime(i)==True:
            print(i)
            break

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

n = int(input())
while True:
  if prime(n):
    break
  else:
    n += 1
print(n)

Submission status: Accepted

Solution code:
from sys import exit
import math
import collections
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x = ii()
while 1:
    cnt = 0
    for i in range(2,math.ceil(x**(1/2)),1):
        if x % i == 0:
            cnt = 1
            break
    if cnt == 0:
        print(x)
        exit()
    x += 1

Submission status: Accepted

Solution code:
import math
def isprime(n):
  if n == 2:
    return True
  elif n % 2 == 0:
    return False
  else:
    for i in range(3,math.ceil(math.sqrt(n))+1,2):
      if n % i == 0:
        return False
    return True

x = int(input())
ans = 0
if x == 2:
  ans = 2
else:
  if x % 2 == 0:
    st = x+1
  else:
    st = x
  for i in range(st,100001):
    if isprime(i) == True:
      ans = i
      break
  if ans == 0:
    ans = 100003
print(ans)

Submission status: Accepted

Solution code:
def prime(n):
    if n <= 1:
        return False
    for i in range(2, n):
        if n % i == 0:
            return False
    return True


X = int(input())
while True:
    if prime(X):
        break
    else:
        X += 1
print(X)

Submission status: Accepted

Solution code:
x = int(input())

def hantei(x):
  p = []
  for i in range(2,int(x**(1/2))+1):
    if (x % i) == 0:
      return False
  else:
    return True
  
while 1:
  if hantei(x):
    print(x)
    break
  else:
    x+=1

Submission status: Accepted

Solution code:
X = int(input())
a = 0
if X == 2 or X == 3:
  print(X)
  exit()
if X % 2 == 0:
  X += 1
for i in range(X , 10 ** 6, 2):
  for j in range(3,i,2):
    a = i % j
    if a == 0:
      break
  if a != 0 :
    print(i)
    exit()

Submission status: Accepted

Solution code:
import sys
def Prime(x):
  for i in range(2, x):
    if(x%i==0):
      return False
  return True

if (__name__=='__main__'):
  X = int(input())
  i = 0
  while True:
    if Prime(X+i):
      print(X+i)
      sys.exit()
    i += 1

Submission status: Accepted

Solution code:
x=int(input())
while True:
  flag=0
  for i in range(2,int(x**0.5)+2):
    if x%i==0:
      flag=1
      break
    else:
      continue
  if x==2:
    flag=0
  if flag==0:
    print(x)
    break
  else:
    x+=1

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Sep  8 20:37:12 2020

@author: liang
"""
import math
X = int(input())
N = int(math.sqrt(X))
lis = list(range(2,N+1))
#print(N)
#print(lis)
ans = X 

while True:
    if all(ans%i != 0 for i in lis):
        print(ans)
        break
    #print(ans)
    ans += 1

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Sep  8 20:25:36 2020

@author: liang
"""

def Eratosthenes(x):
    lis = [int(i) for i in range(2,x+1)]
    #print(lis)
    res = list()
    while lis:
        a = lis.pop(0)
        res.append(a)
        lis = [i for i in lis if i%a != 0]
        #print(lis)
    return res

import math
X = int(input())
N = int(math.sqrt(X))
lis = Eratosthenes(N)
#print(N)
#print(lis)
ans = X 

while True:
    if all(ans%i != 0 for i in lis):
        print(ans)
        break
    ans += 1