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

Solution (Python):
import math

n = int(input())

l = list(range(2,n+1))

ans = n

def isprime(i,k):
    
    if i == 2:
        return True
    
    elif i % 2 == 0:
        return False
    
    else:
        m = math.floor(math.sqrt(k)) + 1
        for n in range(3, m, 2):
            if i % n == 0:
                return False
        
        return True

while True:
    if isprime(ans,n):
        break
    
    ans += 1

print(ans)

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


def isprime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    i = 3
    while i < math.sqrt(n)+1:
        if n % i == 0:
            return False
        i += 2

    return True


def calc(x):
    while not isprime(x):
        x += 1
    return x


print(calc(X))

Solution (Python):
import math

X = int(input())
max_n = int(math.sqrt(X))


def solve(x):
    if x == 2:
        return 2
    if x % 2 == 0:
        x += 1

    for i in range(x, 200001, 2):
        is_prime = True
        for j in range(3, max_n+1, 2):
            if i % j == 0:
                is_prime = False
                break
        if is_prime:
            return i


print(solve(X))

Solution (Python):
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
  
n = int(input())
chk = True
result = 0

while chk:
  if is_prime(n):
    chk=False
    result =n
  n+=1
  
print(result)

Solution (Python):
N = int(input())


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


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

Solution (Python):
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, 100004):
    if is_prime(i):
        print(i)
        exit()

Solution (Python):
import math
N = int(input())

for i in range(N, N + 100):
  for j in range(2, int(math.sqrt(N)) + 1):
    if i % j == 0:
      break
  else:
    print(i)
    break

Solution (Python):
X = int(input())
def prime(N):
    Num = [int(x) for x in range(2,N+1)]
    Prime = []
    limit = int(N**0.5)+1
    while  True:
        p = Num[0]
        if limit <= p:
            return Prime + Num
        Prime.append(p)
        Num = [x for x in Num if x%p != 0]
Pbox = prime(100003)
for i in Pbox:
    if i>= X:
        print(i)
        break

Solution (Python):
import math
X = int(input())
while True:
    pt = 0
    for i in range(2,int(X**0.5)+1):
        if X%i == 0:
            pt = 1
            break
    if pt == 0:
        print(X)
        exit()
    X += 1

Solution (Python):
if __name__ == '__main__':
    x = int(input())
    while True:
        flag = 0
        for i in range(2, x):
            if x % i == 0:
                flag = 1
                break
        if flag == 0:
            print(x)
            exit()
        x += 1

Solution (Python):
x = int(input())

def isPrime(n):
  if n < 2:
    return False
  if n == 2:
    return True
  for p in range(2, n):
      if n % p == 0:
        return False
  return True

while isPrime(x) == False:
  x += 1
print(x)

Solution (Python):
def pin(type=int):
    return map(type,input().split())
X,=pin()

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

Solution (Python):
import math
 
X = int(input())
x=int(math.sqrt(X))


for i in range(X,200001):
    c=0
    for j in range(2,x+1):
        if i%j != 0:
            continue
        else:
            c=1
            break
    if c==0:
        print(i)
        break

Solution (Python):
def judge_prime(num):
    FLAG = True
    
    for i in range(2, int(num**0.5)+1):

        if (num%i == 0):
            FLAG = False
    
    if (num == 2):
        FLAG = True
    
    return(FLAG)

X = int(input())

while (True):
    flag = judge_prime(X)
    
    if (flag):
        break
    
    X += 1

print(X)

Solution (Python):
import numpy as np

def judge_prime(num):
    FLAG = True
    
    for i in range(2, int(num**.5)+1):

        if (num%i == 0):
            FLAG = False
    
    if (num == 2):
        FLAG = True
    
    return(FLAG)

X = int(input())

while (True):
    flag = judge_prime(X)
    
    if (flag):
        break
    
    X += 1

print(X)

Solution (Python):
def judge_prime(num):
    FLAG = True
    
    for i in range(2, int(num**.5)+1):

        if (num%i == 0):
            FLAG = False
    
    if (num == 2):
        FLAG = True
    
    return(FLAG)

X = int(input())

while (True):
    flag = judge_prime(X)
    
    if (flag):
        break
    
    X += 1

print(X)

Solution (Python):
import numpy as np

def judge_prime(num):
    FLAG = True
    
    
    for i in range(2, int(num**0.5)+1):

        if (num%i == 0):
            FLAG = False
    
    if (num == 2):
        FLAG = True
    
    return(FLAG)

X = int(input())

while (True):
    flag = judge_prime(X)
    
    if (flag):
        break
    
    X += 1

print(X)

Solution (Python):
import numpy as np

def judge_prime(num):
    FLAG = True
    
    for i in range(2, int(np.sqrt(num))+1):
        if (num%i == 0):
            FLAG = False
    
    if (num == 2):
        FLAG = True
    
    return(FLAG)

X = int(input())

while (True):
    flag = judge_prime(X)
    
    if (flag):
        break
    
    X += 1

print(X)

Solution (Python):
X = int(input())
for x in range(X,1000000):    
    for i in range(2,x):
        if x%i ==0:
            break
    else:
        print(x)
        break

Solution (Python):
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

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

Solution (Python):
def isPrime(x):
    for i in range(2, int(x**.5)+1):
        if x%i==0:
            return 0
    return 1

x = int(input())

while True:
    if isPrime(x):
        break
    x += 1

print(x)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

X = INT()

def is_prime(num):
   """ 素数判定 """
   from math import sqrt
   if num < 2:
       return False
   if num in [2, 3, 5]:
       return True
   if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
       return False
   
   prime = 7
   step = 4
   num_sqrt = sqrt(num)
   while prime <= num_sqrt:
       if num % prime == 0:
           return False
       prime += step
       step = 6 - step
   return True

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

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

Solution (Python):
x = int(input())

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1


sosu = False

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

print(x-1)

Solution (Python):
from math import sqrt,floor
import sys
n = int(input())
bl = True
for i in range(n,100004):
  bl=True
  for j in range(2,floor(sqrt(n))+1):
    if i % j ==0:
      bl = False
      break
  if bl==True:
    print(i)
    sys.exit()
print(100003)

Solution (Python):
import math

input_from = input()
info = input_from.split(' ')
a = int(info[0])

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

if a > 2:
    if a % 2 == 0:
        a += 1
    while not is_prime(a):
        a += 2

print("{0}".format(a))

Solution (Python):
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
  
N = int(input())
while(True):
  if(is_prime(N)):
    print(N)
    break
  else:
    N += 1

Solution (Python):
n = int(input())

def next_prime(n):
  while True:
    for i in range(2, n):
      if (n % i) == 0:
        break
    else:
      return n
  
    n += 1

print(next_prime(n))

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

Solution (Python):
for i in range(int(input()),100004):
  for j in range(2, i):
    if i % j == 0:
      break
  else:
    print(i)
    break

Solution (Python):
x = int(input())
Primes = [2]
cand = 2
max_prime = 2
while max_prime < x:
  cand = cand + 1
  for prime in Primes:
    if cand % prime == 0:
      break
  else:
    max_prime = cand
    Primes.append(cand)
print(max_prime)

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

Solution (Python):
X = int(input())

while True:
    isDivisible = False
    divider = 2
    while not isDivisible or divider < X:
        isDivisible = (X % divider == 0)

        if isDivisible:
            break
        else:
            divider += 1

    if divider == X:
        break
    else:
        X += 1

print(X)

Solution (Python):

lst=[1 for i in range(0,100001)]

lst[0]=0
lst[1]=0
n=2

while n*n<=100000:
    if lst[n]:
        for i in range(n*n,100001,n):
            lst[i]=0
    n+=1

prinmelist=[]
for i in range(2,len(lst)):
    if lst[i]:
        prinmelist.append(i)
prinmelist.append(100003)
X=int(input())

for i in range(0,len(prinmelist)):
    if X<=prinmelist[i]:
        print(prinmelist[i])
        break

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

Solution (Python):

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

Solution (Python):
X = abs(int(input()))

def isPrime(X):
    for i in range(2, X//2):
        if X % i == 0:
            return False
    return True

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

Solution (Python):
def primes(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]]
n = int(input())  
ps = primes(10 ** 6)
if n == 2:
  print(2)
else:
  for i in range(len(ps)):
    if ps[i] < n <= ps[i + 1]:
      print(ps[i + 1])
      break

Solution (Python):
import bisect


def sieve(n):
    import math
    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]



N = int(input())
A = sieve(10**5+7)

if N in A:
    print(N)
else:
    index = bisect.bisect_right(A,N)
    print(A[index])

Solution (Python):
import math

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

    return True

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

    max = 10 ** 5

    for i in range(x,max+x):
        if is_prime(i):
            ans = i
            break

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
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)

Solution (Python):
def sosu(a):
    import math
    if a == 2:
        return True
    elif (a < 2) or (a % 2 == 0):
        return False
    i = 3
    while i <= round(math.sqrt(a)):
        if a % i == 0:
            return False
        else:
            i+=1
            continue
    return True
x = int(input())
while not sosu(x):
    x+=1
print(x)

Solution (Python):
import itertools
X = int(input())

for x in itertools.count(X):
    
    isprime = all([x % y != 0 for y in range(2,int(x/2)+1)])
    if isprime:
        prime = x
        break

print(prime)

Solution (Python):

import numpy as np
X = int(input())
numList = np.arange(X*2)

for i in range(2,X):
    if numList[i] == False:
        continue
    numList[i:X*2:i] = 0

for i in numList[X:X*2]:
    if i != 0:
        print(i)
        break

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

Solution (Python):
def t(x):
    while True:
        if not any([x % i == 0 for i in range(2, x)]):
            break
        x += 1
    return x


if __name__ == '__main__':
    x = int(input())
    print(t(x))

Solution (Python):
def is_prime(n:int):
    for i in range(2,n+1):
        if i*i>n:
            break
        if n%i==0:
            return False
    return n!=1

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

Solution (Python):
import numpy as np

X = int(input())

nextprime = 0
i = -1

if X >= 4:
  while nextprime == 0:
    i += 1
    amari = 1
    maxnumber = int(np.sqrt(X+i))
    for j in range(2, maxnumber + 1):
      if ((X+i)/j) % 1 == 0:
        amari = 0
        break
    if amari == 1:
      nextprime = X+i  
  
  print(X+i)
  
else:
  print(X)

Solution (Python):
from math import sqrt
X = int(input())
flag = 0
if(X == 1 or X == 2):
  print(2)
else:
  ans = X 
  while(flag == 0):
    for i in range(int(sqrt(ans))):
      if(ans % (i + 2) == 0):
        ans += 1
        flag = 0
        break
      flag = 1
  print(ans)

Solution (Python):
num = int(input())
if num == 2:
    print(2)
    exit()
flag = False
while True:
    for i in range(2, int(num**0.5)+1):
        if num % i ==0:
            flag = False
            break
        else:
            flag = True
    if flag:
        print(num)
        exit()
    else:
        num+=1

Solution (Python):
num = int(input())

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

Solution (Python):
x = int(input())

for i in range(x,10**5+100):
    flg = 'so'
    for j in range(2,x):
        
        if i % j == 0:
            flg = 'no'
            break
   
    if flg == 'so':
        print(i)
        exit()

Solution (Python):
x = int(input())

for i in range(x,10**5+100):
    flg = 'so'
    for j in range(2,x):
        
        if i % j == 0:
            flg = 'no'
   
    if flg == 'so':
        print(i)
        exit()

Solution (Python):
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
n = int(input())
while True:
    if is_prime(n):break
    else:n+=1
print(n)

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

Solution (Python):
def genP():
	yield 2
	yield 3
	c=6
	while 1:
		yield c-1
		yield c+1
		c+=6
def sosu(n):
	if n in [2,3,5]:
		return True
	l=int(n**0.5)+1
	p=genP()
	for i in p:
		if i>l:
			return True
			break
		elif n%i==0:
			return False
			break



def resolve():
	x=int(input())
	while 1:
		if sosu(x):
			print(x)
			break
		else:
			x+=1

resolve()

Solution (Python):
x = int(input())
val = 0
ans = 0
for i in range(x, int(1e20)):
    if i % 2 == 0 and i !=2:
        continue
    for j in range(2,i+1):
        if i == j:
            val = 1         
        
        
        if i % j == 0:
            break

          
    if val == 1:
        ans = i
        break
    
print(ans)

Solution (Python):
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

Solution (Python):
x=int(input())
from numpy import mod

if x <= 3:
    ans=x
    prime=True
elif mod(x,2)==0:
    prime=False
else:
    
    for i in range(3,x+1,2):
        if mod(x,i)==0:
            if i==x:
                prime=True
                ans=x
            else:
                prime=False
                break
if prime==False: 
    if mod(x,2)==0:
        x2=x-1
    else:
        x2=x-2
            
    while (prime==False):
        x2= x2+2
        prime=True
        for i in range(3,x2+1,2):
            if mod(x2,i)==0:
                if i==x2:
                    prime=True
                    ans=x2
                else:
                    prime=False
                    break
    

print(ans)

Solution (Python):
x = int(input())
prim = x
flag = True

while(flag):
  if x==2:
    break
  for j in reversed(range(2, x)):
    if x % j == 0:
      
      flag = True
      break
    else:
      prim = x
      flag = False
  x += 1
print(prim)

Solution (Python):
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())
    while True:
        if is_prime(X):
            print(X)
            exit()
        X+= 1

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np































































X = int(input())
XX=np.arange(X,X+10**4)

s=0
for j in XX:
    if (s==1):
        break
    for i in range(2, j+1):
        N= j % i

        if (N ==  0 and i==j ):
            print(j)
            s=1
        if (N ==  0):
          
            break

Solution (Python):
X = int(input())

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

Solution (Python):
import math

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

Solution (Python):
c=int(input())
s=10**5
s+=100
sosu_flag=[True if i%2==1 else False for i in range(s)]
sosu_flag[1]=False
sosu_flag[2]=True
for i in range(3,s,2):
    if not sosu_flag[i]:
        continue
    for j in range(i+i,s,i):
        sosu_flag[j]=False
sosu=[]
for i in range(s):
    if sosu_flag[i]:
        sosu.append(i)
ans=c+sosu_flag[c:].index(True)
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**5)


X = int(input())


def is_prime(x):
    if x < 2:
        return False
    
    i = 2
    while i*i <= x:
        if x % i == 0:
            return False
        i += 1
    
    return True
    
x = X
while not is_prime(x):
    x += 1


print(x)

Solution (Python):
def is_prime(x):
    for i in range(2, x):
        if x % i == 0:
            return False
    return True


def main():
    x = int(input())
    while True:
        if is_prime(x):
            print(x)
            return
        x += 1


main()

Solution (Python):

X = int(input())

if X == 2:
    print(2)
else:
    prime_number_list = list()
    prime_number_list.append(2)

    import math
    
    i = 3
    
    continue_flag = True
    
    while continue_flag:
        
        
        
        for prime_number in prime_number_list:
            
            
            if i%prime_number == 0:
                
                break
            elif prime_number > math.sqrt(i):
                
                prime_number_list.append(i)
                
                if i >= X:
                    print(i)
                    continue_flag = False
                break
        
        i += 1

Solution (Python):
p = int( input())
import math

while True:
  is_composite_number = False
  for i in range( 2, int( math.sqrt( p ))):
    is_composite_number = is_composite_number or ( p % i == 0 )
  if not is_composite_number:
    break
  p += 1
print( p )

Solution (Python):
import math
X=int(input())
def isPrime(n):
    if n == 1: return False

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

    return True
  

if X==2:
    print(2);exit()
else:
  if X%2==0:
    X+=1
      
while True:  
  if isPrime(X):
    print(X);exit()
  
  X+=2

Solution (Python):
n = int(input())
if n == 2:
    print(2)
    exit()
for i in range(n, 10**6):
    for p in range(2, i):
        if i % p == 0:
            break
        elif i-1 == p:
            print(i)
            exit()

Solution (Python):
import math
array=[2]
for i in range(3,100004,2):
    prime=True
    for n in range(len(array)):
        if array[n] > math.sqrt(i):
            break
        if i % array[n] == 0:
            prime = False
            break
    if prime:
        array.append(i)
l=int(input())
for m in range(len(array)):
    if l>array[m]:
        pass
    else:
        print(array[m])
        break

Solution (Python):
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):
  if is_prime(X) == True:
    print(X)
  else:
    return main(X+1)

if __name__ == '__main__':
  X = int(input())
  main(X)

Solution (Python):


import sys
import math
import time
import numpy as np
import collections


X = int(raw_input())

k = X
flag = 0


while True:
  flag = 0
  for p in xrange(2, int(math.sqrt(k))+1):
    if k % p == 0:
        flag = 1
        break
  if(flag == 0):
    ans = k
    break
  k += 1



print(str(ans));

Solution (Python):
n = int(input())
x = 10**6
li = [True for i in range(x+10)]
li[0] = False
li[1] = False

for i in range(int(x**0.5)+1):
    if li[i]:
        m = 2
        while(i*m<=x):
            li[i*m] = False
            m += 1

for i in range(x):
    if i>=n and li[i]:
        print(i)
        break

Solution (Python):
x = int(input())
while True:
  xs = [i for i in range(1, x + 1) if x % i == 0]
  if len(xs) == 2:
    break
  x += 1
print(x)

Solution (Python):
X = int(input())
def isprime(n): 
    import math as ma
    if n == 2 or n == 3:
        return True
    if n % 2 == 0 or n % 3 == 0:
        return False
    for i in range(6, (int(ma.sqrt(n))+1) + 1, 6):
        if n % (i-1) == 0 or n % (i+1) == 0: 
            return False
    return True
while True:
    if isprime(X):
        print(X)
        break
    X += 1

Solution (Python):
primes = [2]

X = int(input())


def is_prime(n):
    for p in primes:
        if n < p * p:
            break
        if n % p == 0:
            return False
    return True


for i in range(3, X, 2):
    if is_prime(i):
        primes.append(i)

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

Solution (Python):
X=int(input())
sqrt_X=int(X**0.5)

while True:
  if all([X%i!=0 for i in range(2,sqrt_X+1)]):
    print(X)
  else:
    X+=1
    continue
  break

Solution (Python):
import math

n = int(input())


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


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

Solution (Python):
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

tmp = seachPrimeNum(100021)
n = int(input())
for i in tmp:
    if n <= i:
        print(i)
        break

Solution (Python):
from bisect import bisect_left

X = int(input())

p = [1]*(10**5+4)
for i in range(2, 10**5+4):
    if p[i]:
        for j in range(i*2, 10**5+4, i):
            
            p[j] = 0

q = []
for i, p_i in enumerate(p):
    if p_i:
        q.append(i)

print(q[bisect_left(q, X)])

Solution (Python):

import numpy as np

n = 100003 

primes = np.ones((n + 1,), dtype=int)
primes[0] = 0
primes[1] = 0
primes[2*2::2] = 0
primes[3*2::3] = 0
m = 5
l = n ** 0.5
while m <= l:
    if primes[m]:
        primes[m * 2::m] = 0
    if m % 6 == 5:
        m += 2
    else:
        m += 4


X = int(input())

while True:
    if primes[X]:
        print(X)
        break
    X += 1

Solution (Python):

import numpy as np

n = 100003 

primes = np.ones((n + 1,), dtype=int)
primes[0] = 0
primes[1] = 0
primes[2*2::2] = 0
primes[3*2::3] = 0
m = 5
l = n ** 0.5
while m <= l:
    if primes[m]:
        primes[m * 2::m] = 0
    if m % 6 == 5:
        m += 2
    else:
        m += 4

primes = primes.nonzero()[0]


X = int(input())
idx = np.where(primes >= X)[0][0]
print(primes[idx])

Solution (Python):
import math as m
def isprime(n):
  
  
  d = int(m.sqrt(n))
  for i in range(2, d):
    if n%i==0:
      return False
  return True

n = int(input())

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

Solution (Python):
def miller_rabin(n):
    """ primality Test
        if n < 3,825,123,056,546,413,051, it is enough to test
        a = 2, 3, 5, 7, 11, 13, 17, 19, and 23.
        Complexity: O(log^3 n)
    """
    assert(n >= 1)
    if n == 2:
        return True
    if n <= 1 or not n & 1:
        return False

    primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]

    d = n - 1
    s = 0
    while not d & 1:
        d >>= 1
        s += 1

    for prime in primes:
        if prime >= n:
            continue
        x = pow(prime, d, n)
        if x == 1:
            continue
        for r in range(s):
            if x == n - 1:
                break
            if r + 1 == s:
                return False
            x = x * x % n
    return True


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

Solution (Python):
import math

X = int(input())

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

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

Solution (Python):
a = [True]*110000
n = 110000
for i in range(2, int(n**0.5) + 1):
	if a[i]:
		for i in range(i*i, n, i):
			a[i] = False
s = int(input())
ans = None
start = s
while not a[start] :
	start += 1
print(start)

Solution (Python):
M = 10 ** 6
e = 10 ** 3


primes = [True] * (M + 1)
primes[0] = False
primes[1] = False
for i in range(2, e):
    if primes[i]:
        for j in range(i * 2, M + 1, i):
            primes[j] = False

X = int(input())

print(X + primes[X:].index(1))

Solution (Python):
def primeCheck(a):
  i=2
  if a<=1:
    return False
  while(i*i<=a):
    if a%i==0:
      return False
    i+=1
  return True

X=int(input())
p=X
while(primeCheck(p)!=True):
  p+=1
print(p)

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

Solution (Python):
from sys import stdin
input = int(stdin.readline())
flag = False
if input == 2:
    flag = True
    output = 2
else:
    for i in range(input, 1000000):
        sqrt_i = int(i ** (1/2)) + 1
        flag = True
        for j in range(2, sqrt_i + 1):
            if i % j == 0:
                flag = False
        if flag:
            output = i
            break
print(output)

Solution (Python):
x = int(input())

def prime(n):
    ans = "yes"
    for i in range(2,round(n**0.5)+1):
        if n%i == 0:
            ans = "no"
            break
        else:
            continue
    if ans == "yes":
        return n
    else:
        return prime(n+1)
    

if x == 2 or x == 3:
    print(x)
else:
    print(prime(x))

Solution (Python):

import sys
def input():
    return sys.stdin.readline().rstrip()
def main():
    X=int(input())

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

    while isprime(X) == False:
        X += 1
    print(X)



if __name__ == '__main__':
    main()

Solution (Python):
"""2ずつインクリメントして素数か検証"""
def NextPrime(X):
        while True:
                flag = 1
                for i in range(3, round(X**(1/2)), 2):
                        if X % i == 0:
                                flag = 0
                                break
                if flag == 1:
                        return X
                X += 2


X = int(input())

if X == 2:
        print(X)
        exit()
elif X %2 == 0:  
        X += 1

print(NextPrime(X))

Solution (Python):
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

def main():
    N = int(input())
    ls = makePrimeChecker(10**6)
    for i in range(N,10**6+1):
        if ls[i]:
            print(i)
            exit()
        

if __name__ == '__main__':
    main()

Solution (Python):
import math

def resolve():
    X = int(input())
    answer = prime_number_from_X(X)

    print("{}".format(answer))


def prime_number_from_X(X):
    i = X
    while True:
        i_sqrt = int(math.sqrt(i))
        is_prime_number = False
        if X == 2:
            return 2
        for j in range(2, i_sqrt):
            if i % j == 0:
                is_prime_number = False
                break
            else:
                is_prime_number = True
        if is_prime_number:
            return i
        i += 1

if __name__ == "__main__":
    resolve()

Solution (Python):

import math

X = int(input())


def isPrime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False
    
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i += 2    
    return True

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