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:
def prime(n):
    is_prime=[True]*(n+1)
    is_prime[0],is_prime[1]=False,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]]


n=int(input())
prime=prime(10**6)
for i in prime:
    if i>=n:print(i);exit()

Submission status: Accepted

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
# # input = sys.stdin.readline    ####
# def int1(x): return int(x) - 1
def II(): return int(input())

# def MI(): return map(int, input().split())
# def MI1(): return map(int1, input().split())
#
# def LI(): return list(map(int, input().split()))
# def LI1(): return list(map(int1, input().split()))
# def LLI(rows_number): return [LI() for _ in range(rows_number)]
#
# def SI(): return input().split()
#
# def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
# INF = float('inf')
#
# from math import ceil, floor, log2, sqrt
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
# from heapq import heapify, heappop, heappush

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

    return True


def solve():
    X = II()

    while 1:
        if is_prime(X):
            print(X)
            return

        X += 1



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2, sqrt
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush

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

    return True


def solve():
    X = II()

    while 1:
        if is_prime(X):
            print(X)
            return

        X += 1



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush

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

    return True


def solve():
    X = II()

    while 1:
        if is_prime(X):
            print(X)
            return

        X += 1



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    X = II()

    while 1:
        for i in range(2, int(pow(X, 0.5))+1):
            if X % i == 0:
                break
        else:
            print(X)
            return

        X += 1



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    X = II()

    while 1:
        for i in range(2, X):
            if X % i == 0:
                break
        else:
            print(X)
            return

        X += 1



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
X = int(input())

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

if X % 2 == 0:
    f = X+1
else:
    f = X

#fが素数かどうかをしらべていく。
while True:
    flag = True
    for i in range(2, int(f**0.5)+1):
        #fが素数ではないことを確認したら
        if f % i == 0:
            ｆ += 2
            flag = False
            break
    if flag:
        print(f)
        break

Submission status: Accepted

Solution code:
x = int(input())

for i in range(x, 10**5 + 4):
    flag = True
    for j in range(2, i):
        if (i % j == 0):
            flag = False
            continue
    if flag:
        print(i)
        break
    else:
        continue

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[6]:


X = int(input())


# In[7]:


ans = X
while True:
    flg = False
    for i in range(2,ans+1):
        if i < ans:
            if ans%i == 0:
                ans += 1
                break
        else:
            flg = True
    if flg:
        break
print(ans)


# In[ ]:

Submission status: Accepted

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

def SieveOfEratosthenes(n):
    prime_list = [True] * (n+1)
    p = 2
    while (p ** 2 <= n):
        if prime_list[p]:
            for i in range(p ** 2, n+1, p):
                prime_list[i] = False
        p += 1
    return prime_list

def main():
    X = int(input())
    N = 10 ** 6 + 500
    prime_idx = SieveOfEratosthenes(N)
    primes = [val for val, idx in zip(range(N+1), prime_idx) if idx]
    ans = [x for x in primes if x >= X]
    print(ans[0])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    x = gete(int)
    MAX_I = 100005
    p = [True] * MAX_I
    p[0], p[1] = False, False

    for i in range(2, MAX_I):
        if p[i]:
            for j in range(2 * i, MAX_I, i):
                p[j] = False

    for i in range(x, MAX_I):
        if p[i]:
            print(i)
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import bisect
x = int(input())
def primes(max_number):
    pr = list(range(3, max_number+1, 2))
    lpr = len(pr)
    for i,n in enumerate(pr):
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, lpr, n):
                pr[j] = 0
    yield 2
    yield from[i for i in pr if i]

a = list(primes(101000))
bi = bisect.bisect(a, x)
if a[bi-1] == x:
    print(x)
else:
    print(a[bi])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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, 1000000):
    if is_prime(i) == True:
        break
print(i)

Submission status: Accepted

Solution code:
def f(n):
    if n==2:return 2
    for i in range(2,[n, 5][n>5]):
        if i**n%n != i:
            return f(n+1)
    return n
print(f(int(input())))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
if X == 2:
  y = 2
elif X%2 ==0:
  y = X+1
else:
  y = X
Flag = True
while Flag == True:
  a = int(y**(1/2))
  t = 0
  for i in range(2,a):
    if y % i == 0:
      t = 1
  if t == 0:
    Flag = False
  y += 1
print(y-1)

Submission status: Accepted

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


def solve(X: int):
    for x in range(X, 200003):
        if is_prime(x):
            print(x)
            break
    return


def is_prime(n: int):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

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


# 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:
X=int(input())
while True:
    for i in range(2,X-1):
        if X%i==0:
            X+=1
            break
    else:
        print(X)
        exit()

Submission status: Accepted

Solution code:
N = int(input())

for i in range(N,10**10):
    f = 0
    for j in range(2,i-1):
        #print(i , j)
        if i % j == 0:
            f += 1
            break
    if f == 0:
        print(i)
        exit()

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


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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

X = int(input())
if X == 2:
    print(2)
    sys.exit()
if X%2 == 0:
    X += 1
while not checkPrime(X):
    X += 2
print(X)

Submission status: Accepted

Solution code:
def is_prime(p):
  if p>1:
    for i in range(2,p):
      if p%i==0:return True
  return False

X=int(input())
p=X
while is_prime(p) != False:p+=1
print(p)

Submission status: Accepted

Solution code:
x = int(input())

while True:
  ok = True
  i = 2
  while i * i <= x:
    if x % i == 0:
      ok = False
      break
    i += 1
  if ok:
    print(x)
    break
  x += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import sqrt


def isPrime(n):
    if n > 2 and n % 2 == 0: return False
    i = 3
    while i <= sqrt(n):
        if n % i == 0:
            return False
        i += 2
    return n > 1


n = int(input())
while not isPrime(n):
    n += 1
print(n)

Submission status: Accepted

Solution code:
X=int(input())

import math
def prime_num(k):
    for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
                return False
    else:
        return True
      
for i in range(X,100010):
    if prime_num(i)==True:
        print(i)
        break

Submission status: Accepted

Solution code:
x = int(input())

flag = False
next = False
while not flag:
    for i in range(2, x, 1):
        if x%i == 0:
            next = True
            break
    if next:
        x += 1
        next = False
        continue
    else:
        print(x)
        exit()

Submission status: Accepted

Solution code:
x = int(input())

ans = 0

for i in range(x, 100004):
    tmpf = 1
    for j in range(2, int(i**0.5)):
        if i % j == 0:
            tmpf = 0
            break
    if tmpf == 1:
        ans = i
        break
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
x = int(input())
a = int(x/2) + 1
while 1:
  for i in range(2,a):
    if not x % i:
      x += 1
      break
  else:
    ans = x
    break

print(ans)

Submission status: Accepted

Solution code:
import math
x = int(input())
a = int(x/2) + 1
while 1:
  for i in range(2,a):
    if not x % i:
      x += 1
      break
  else:
    ans = x
    break

print(ans)

Submission status: Accepted

Solution code:

x = int(input())

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

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

  if comp :
    x += 2

print(x)

Submission status: Accepted

Solution code:
NumPri = int(input())
Triger = 0
while True:
  for i in range(2,NumPri):
    if NumPri%i == 0:
      NumPri += 1
      Triger += 1
      break
  if Triger == 1:
    Triger = 0
    continue
  print(NumPri)
  break

Submission status: Accepted

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


def solve(X: int):
    primes = get_prime_numbers_array(2 * (10**5))
    for i, v in enumerate(primes):
        if v and i >= X:
            print(i)
            return
    return


def get_prime_numbers_array(n: int):
    """エラトステネスのふるいを用いてnまでの素数判定を行うための配列を返す"""
    N = n + 1
    is_prime = [1] * N
    is_prime[0] = is_prime[1] = 0
    for i in range(2, N):
        if not is_prime[i]:
            continue
        for j in range(i * 2, N, i):
            is_prime[j] = 0
    return is_prime


# 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:
X = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

while True:
    flag = True
    for i in range(2,x):
        if x%i==0:
            flag = False
    if flag:
        print(x);exit()
    else:
        x+=1

Submission status: Accepted

Solution code:
x = int(input())
while any(x % i == 0 for i in range(2,x)):
    x += 1
print(x)

Submission status: Accepted

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

def isprime(n):
    for i in range(2,math.ceil(math.sqrt(n))):
        if n%i == 0:
            return False
    return True

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

print(X)

Submission status: Accepted

Solution code:
x=int(input())

while True:
  i=2
  ok=True
  while i*i<=x:
    if x % i == 0:
      ok=False
      break
    i+=1
  if ok:
    print(x)
    break
  x+=1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
num = X

def isPrime(num):
	if num == 1 or num == 2:
		return True
	for i in range(2,num):
		if num % i == 0:
			return False
	return True


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

Submission status: Accepted

Solution code:


x = int(input())
result = True
hantei = False
sum = 0


while hantei == False:
    hantei = True

    for i in range(2,x):
        
        if x % i == 0:
            hantei = False
            break

    
    


    x += 1

print(x-1)

Submission status: Accepted

Solution code:
import math


def li():
    return list(map(int, input().split()))


def mi():
    return map(int, input().split())


def ii():
    return int(input())


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


def next_prime(n):
    i = n
    while True:
        if is_prime(i):
            return i
        i += 1


X = ii()

print(next_prime(X))

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
X = int(input())

def check(num):
    max_div = int(num**0.5)
    for div in range(2, max_div+1):
        if num % div == 0:
            return False
    else:
        return True

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

Submission status: Accepted

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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


def main():
    X = int(readline())
    while not is_prime(X):
        X += 1
    print(X)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = int(input())

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

while(1):
    if(is_prime(x)):
        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())
while True:
    if is_prime(x):
        print(x)
        break
    else:
        x += 1

Submission status: Accepted

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

X = int(input())

for i in range(X, 100004):
    if is_prime(i):
        print(i)
        break

Submission status: Accepted

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

X = int(input())

for i in range(X, 100004):
    if is_prime(i):
        print(i)
        break

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for i in range(x,2*x):
    s = 0
    for j in range(2,int(pow(i,0.5))+1):
        if i%j == 0:
            s = 1
            break
    if s == 0:
        break
print(i)

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
if x <= 3:
    i = x
else:
    for i in range(x,2*x):
        s = 0
        for j in range(2,int(pow(i,0.5))+1):
            if i%j == 0:
                s = 1
                break
        if s == 0:
            break
print(i)

Submission status: Accepted

Solution code:
import math

def isPrime(num):
    if num < 2:
        return False
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False

    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False
    
    return True


def find_min_prime(num):
    if num == 2:
        return 2
    if num % 2 == 0:
        num +=1

    while True:
        if isPrime(num):
            break
        num += 2
        
    return num


X = int(input())
print(find_min_prime(X))

Submission status: Accepted

Solution code:
def countyakusu(n):
	yakusuu=[]
	for i in range(1,int(n**0.5)+1): 
		if n%i==0:
			yakusuu.append(i)
			if i!=n//i:
				yakusuu.append(n//i)
	return yakusuu
x = int(input())
for i in range(x,10**6):
	cnt = countyakusu(i)
	if len(cnt) == 2:
		print(i)
		break

Submission status: Accepted

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

n = int(input())

for i in range(n,10**6):
  if isPrime(i):
    print(i)
    break

Submission status: Accepted

Solution code:
m=int(input())

for j in range(m,1000000):
    #print(j)
    pf={}
    for i in range(2,int(j**0.5)+1):
        while j%i==0:
            pf[i]=pf.get(i,0)+1
            j//=i
    if j>1:pf[j]=1
    #print(pf)
    if sum(pf.values())==1:
        print(j)
        exit()

Submission status: Accepted

Solution code:
primes = set([2])
X = int(input())
if X == 2:
    print(2)
else:
    for i in range(3, int(X ** .5) + 1, 2):
        for p in primes:
            if i % p == 0:
                break
        else:
            primes.add(i)
    # print(f"primes:{primes}", file=sys.stderr)
    x = X
    if x % 2 == 0:
        x += 1
    found = False
    while not found:
        for p in primes:
            if x % p == 0:
                break
        else:
            print(x)
            found = True
        x += 2

Submission status: Accepted

Solution code:
X=int(input())
a=True
b=True
ans=0

while a==True:
    for i in range(X-1):
        if X==i+2:
            a=False
            ans=X
        if X%(i+2)==0 and X!=i+2:
            break
    X+=1

print(ans)

Submission status: Accepted

Solution code:
X = int(input())
i =0
while i <= X:
    for i in range(2,X+1):
        mod = X%i
        if mod ==0 : 
            if i == X:
                print(X)
                break
            elif i < X:
                X = X+1
    i = i+1

Submission status: Accepted

Solution code:
serach_number = int(input())

def search_prime_number(target):
 
    for i in range(2,serach_number-1 ):
        if target % i == 0:
            return False
    return True

while True:
  if search_prime_number(serach_number):
    print(serach_number)
    break
  serach_number+=1

Submission status: Accepted

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

def search_prime_number(target):
    square  = int(math.sqrt(target))
 
    for i in range(2,square ):
        if target % i == 0:
            return False
    return True

while True:
  if search_prime_number(serach_number):
    print(serach_number)
    break
  serach_number+=1

Submission status: Accepted

Solution code:
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

def main():
    x = int(input())
    for i in range(x, 10**10+1):
        if is_prime(i):
            print(i)
            return
        

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

def main():
    #input
    ans=0
    X=int(input())
    for j in range(X):
        if prime(X+j):
            ans=X+j
            break
    print(ans)
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
def prime(num):
  for p in range(2, num):
    if num % p == 0:
      return False
    else:
      continue
    return True


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

Submission status: Accepted

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

for i in range(n,n+400):
  if is_prime(i):
    print(i)
    break

Submission status: Accepted

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

def trial_division(target):
    dest = int(math.sqrt(target))
 
    for i in range(2,dest):
        if target % i == 0:
            return False
    return True

while True:
  if trial_division(serach_number):
    print(serach_number)
    break
  serach_number+=1

Submission status: Accepted

Solution code:
x = int(input())
i = 2
while True:
    while i * i <= x:
        if x % i == 0:
            break
        i += 1
    else:
        print(x)
        exit()
    i = 2
    x += 1

Submission status: Accepted

Solution code:
n=int(input())
f=0
while 1:
    for i in range(2,n//2+1):
        if n%i==0:
            break
        elif i==n//2:
            f=1
            break
    if n==2:
        print(2)
        break
    if f==1:
        print(n)
        break
    n+=1

Submission status: Accepted

Solution code:
x = int(input())


def is_prime(n, i=2):
    if (n % i == 0):
        return False
    elif (i * i > n):
        return True

    return is_prime(n, i + 1)


if x > 3:
    while(is_prime(x) == False):
        x += 1

print(x)

Submission status: Accepted

Solution code:
x = int(input())


def is_prime(n, i=2):
    #if (n == 2):
    #    return True
    #elif (n % i == 0):
    if (n % i == 0):
        return False
    elif (i * i > n):
        return True

    return is_prime(n, i + 1)

if x > 3:
    while(is_prime(x) == False):
        x += 1

print(x)

Submission status: Accepted

Solution code:
x = int(input())


def is_prime(n, i=2):
    if (n == 2):
        return True
    elif (n % i == 0):
        return False
    elif (i * i > n):
        return True

    return is_prime(n, i + 1)


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

print(x)

Submission status: Accepted

Solution code:
x = int(input())


def prime(n):
    flag = ''
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            break
    else:
        flag = 'prime_number'

    return(flag)


while(prime(x) != 'prime_number'):
    x += 1

print(x)

Submission status: Accepted

Solution code:
x = int(input())


def prime(n):
    flag = ''
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            break
    else:
        flag = 'prime_number'

    return(flag)


if x == 2:
    print(2)
else:
    i = x + int(x % 2 == 0)

    while(prime(i) != 'prime_number'):
        i += 1

    print(i)

Submission status: Accepted

Solution code:
x = int(input())


def prime(n):
    flag = ''
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            break
    else:
        flag = 'prime_number'

    return(flag)


if x == 2:
    print(2)
else:
    i = x + int(x % 2 == 0)

    while(True):
        if prime(i) == 'prime_number':
            break

        i += 1

    print(i)

Submission status: Accepted

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

x = int(input())
if x!=2 and x%2==0:
    x+=1
for i in range(x, 10**6, 2):
    if is_prime(i):
        print(i)
        break

Submission status: Accepted

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

x = int(input())
for i in range(x, 10**6):
    if is_prime(i):
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

def prime_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

if x == 1:
    print(2)
    exit()
i = 0
while True:
    a = prime_factorize(x + i)
    if len(a) == 1:
        print(x + i)
        exit()
    i += 1

Submission status: Accepted

Solution code:
x = int(input())
for i in range(x,x+100):
    for j in range(2,i//2):
        if i%j==0:
            break
    else:
        print(i)
        break

Submission status: Accepted

Solution code:
x = int(input())
flag = 0
flag2 = 0
div = 2
roop = 0
ans = []
while flag2 == False:
    if x == 2 or x == 3:
        ans = x
        break
    while flag == False:
        roop += 1
        if x%div == 0:
            break
        elif x%div != 0:
            if div%2 == 0:
                div += 1
            elif div <= x*0.5:
                div +=2
            else:
                ans = x
                break
    if x%2 == 0:
        x += 1
    else:
        x += 2
    div = 2
    if ans != []:
        flag2 = 1

print(ans)

Submission status: Accepted

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

def isPrime(n):
    check = 1
    nsq = int(math.sqrt(n))
    for i in range(2,nsq+1):
        if n % i != 0:
            check += 1
        else:
            pass
            
    if check == nsq:
        return True
    else:
        False

for i in range(x):
    if isPrime(x+i):
        print(x+i)
        break
    else:
        pass

Submission status: Accepted

Solution code:
import sys
x=int(input())
if x==2:
    print(2)
    sys.exit()
while True:
    flag=-1
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            flag=1
    if flag==-1:
        print(x)
        sys.exit()
    x+=1