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

x=int(input())


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

for i in range(x,10**6):
  if isPrime(i):
    print(i)
    exit(0)

Solution (Python):
def prime(x):
    if x in [2,3,5,7,11]:
        return 1
    elif x % 2 ==0:
        return 0
    else:
        p=3
        while p*p <= x:
            if x % p ==0:
                return 0
            else:
                p += 2
        return 1


N=int(input())
for i in range(100):
    if prime(N+i):
        print(N+i)
        break

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

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

Solution (Python):
n = int(input())
mx = 100004
array = [1 for _ in range(mx)]
array[0] = array[1] = 0
for i in range(4, mx, 2):
    array[i] = 0
for i in range(3, mx, 2):
    if not array[i]:
        continue
    for j in range(i+i, mx, i):
        array[j] = 0
for i in range(n, mx):
    if array[i]:
        print(i)
        break

Solution (Python):
import math

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


x = int(input())

while True:
    if check_prime(x):
        print(x)
        exit()
    x += 1

Solution (Python):



class Prime(object):
    '''Represents a snippet for prime numbers.
    '''

    def __init__(self, number):
        self.number = number
        self._values = []

    def is_included(self) -> bool:
        '''Determine whether it is a prime number.
        Args:
            number: Int of number (greater than 0).
        Returns:
            True if the input number was prime.
            False if the input number was not prime.
        See:
            https://qiita.com/srtk86/items/874639e361917e5016d4
            https://docs.python.org/ja/3/library/2to3.html?highlight=isinstance
        '''

        from math import sqrt

        if (self.number <= 1) or (isinstance(self.number, float)):
            return False

        for i in range(2, int(sqrt(self.number)) + 1):
            if self.number % i == 0:
                return False

        return True

    def generate(self) -> list:
        '''Generate a list of prime numbers using sieve of Eratosthenes.
        Returns:
            A list of prime numbers that is eqaul to or less than the input
            number.
        Landau notation: O(n log log n)
        See:
            https://beta.atcoder.jp/contests/abc110/submissions/3254947
        '''

        if self._values:
            return self._values

        is_met = [True for _ in range(self.number + 1)]
        is_met[0] = False
        is_met[1] = False

        for i in range(2, self.number + 1):
            if is_met[i]:
                self._values.append(i)

                for j in range(2 * i, self.number + 1, i):
                    is_met[j] = False
        return self._values


def main():
    x = int(input())
    ps = Prime(2 * 10 ** 5)

    for pi in ps.generate():
        if pi >= x:
            print(pi)
            exit()


if __name__ == '__main__':
    main()

Solution (Python):
x = int(input())
l = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313]

l = [ i for i in l if i < x]

m = [x % i for i in l]

while True:
    if not any(t == 0 for t in m):
        break
    m = [(i + 1) % l[n] for n, i in enumerate(m)]
    x += 1
print(x)

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

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

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

mod=10**7+9
for i in range(x,mod):
  if not any(i%j==0 for j in range(2,i+1-1)):
    ans=i
    break
    
print(ans)

Solution (Python):
def isPrime(n) : 
  
    
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True
  
    
    
    if (n % 2 == 0 or n % 3 == 0) : 
        return False
  
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
  
    return True
x=int(input())
while True:
  if isPrime(x):
    print(x)
    break
  x+=1

Solution (Python):


x=int(input())

def is_prime(p):
  cnt=0
  for i in range(2,p):
    if p%i==0:
      cnt+=1
  if cnt==0:
    return True
  
  else:
    return False
      

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

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

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

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

Solution (Python):
import math
def judge(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False
    return True

X = int(input())
ret = 0
for i in range(X, 10**9):
    if judge(i):
        ret = i
        break
print(ret)

Solution (Python):
from sys import stdin
import math


def isPrime(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(stdin.readline().rstrip())
while not isPrime(x):
    x += 1
print(x)

Solution (Python):
x=int(input())
tempX=x
num=[]
ans=0
for i in range(x):
  if i!=0:
    if i !=1:
      num.append(i)
if x==2:
  ans=2
while ans==0:
  for i in num:
    if tempX%i == 0:
      tempX=tempX+1

      break
    if i==num[-1]:
      ans = tempX
print(ans)

Solution (Python):
import math
def isPrime(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(not isPrime(x)):
    x += 1
print(x)

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

def isPrime(n):
    if n == 2:
        return True
    if n == 1 or n % 2 == 0:
        return False
    for p in range(3, int(n**0.5)+1, 2):
        if n % p == 0:
            return False
    return True

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

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

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

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

isPrime = [True] * 1000000
for p in range(2, 1000000):
    if not isPrime[p]:
        continue
    if p >= X:
        print(p)
        break
    for i in range(p + p, 1000000, p):
        isPrime[i] = False

Solution (Python):
def getdata_input():
    while True:
        yield input()
def callFunc2(it):
    N=int(next(it))
    prime=[x for x in range(2,2*N+1)]
    a=[-1]*(2*N+1)
    lp=0
    for x in prime:
        if lp >= N:
            break
        if a[x]!=-1:
            continue
        c=1
        i=x*c

        while i < 2*N+1:
            lp=x
            a[i]=x
            c+=1
            i=x*c
    return(str(lp))   
it=getdata_input()
print(callFunc2(it))

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

def judgePrime(a):
	for k in range(2, int(a**(1/2)) + 1):
		if a % k == 0:
			return False
	return True

while True:
	if judgePrime(x):
		print(x)
		exit()
	else:
		x += 1

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

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

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

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
  
hantei=False
while hantei==False:
  X +=1
  hantei=is_prime(X-1)
print(X-1)

Solution (Python):
def j_p(a):
    if a<=1:
        return False
    else:

        for i in range(2,a):
            if i**2>a:
                break
            else:
                if a%i==0:
                    return False
                else:
                    continue
        return True
x=int(input())
p=x
while j_p(p)==False:
    p+=1
print(p)

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
from fractions import gcd
from itertools import count
from functools import lru_cache
from collections import defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok


def main():
    x = ii()
    ps = []
    for i in count(2):
        is_prime = True
        for p in ps:
            if i % p == 0:
                is_prime = False
                break
            if i**0.5 < p:
                break 
        if is_prime:
            if x <= i:
                print(i)
                return
            else:
                ps.append(i)

main()

Solution (Python):
import math
 
x = int(input())
i = x
def prime(i):
    for j in range(2,math.ceil(math.sqrt(i))):
        if i%j == 0:
            return False
    return True

while True:
    if prime(i):
        print(i)
        break
    else:
        i += 1

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

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


while True:
    divisors = make_divisors(x)
    if len(divisors) == 2:
        print(x)
        exit(0)
    x += 1

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

x = X
cnt = 0
prime_num_cnt = False

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

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

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

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

flag=True
while flag:
    for i in range(1,a):
        if(i==a-1):

            flag=False
        elif(a%i==0 and i!=1):
            a+=1
            break
print(a)

Solution (Python):



X = int(input())

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

Solution (Python):


def eratosthenes(n):
    numbers = [True] * (n + 1)
    primes = []
    for i in range(2, int(n ** 0.5 + 1)):
        if numbers[i]:
            for j in range(i*i, n + 1, i):
                numbers[j] = False
    for i in range(n+1):
        if numbers[i]:
            primes.append(i)
    return primes





primes = eratosthenes(1000000)
given = int(input())
for i in primes:
    if i >= given:
        print(i)
        break

Solution (Python):
x=int(input())
sosu=[False]*(10**5+4)
for i in range(2,10**5+4):
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            break
    else:
        sosu[i]=True
for i in range(x,10**5+4):
    if sosu[i]:
        print(i)
        break

Solution (Python):
def is_prime(x):
    if x <= 1:
        return False

    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1

    return True


x = int(input())

p = x

while not is_prime(p):
    p += 1

print(p)

Solution (Python):
x =int(input())
n = 2*10**5

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

for i in range(x-1,n):
    if is_prime[i]==True:
        print(i+1)
        break

Solution (Python):
import math
def isprime(n):
    if n==1:return(False)
    if n==2:return(True)
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:return(False)
    return(True)
n=int(input())
for i in range(n,10**6):
    if isprime(i):
        print(i)
        exit()

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

def using_sqrt(k):
    factor = 0
    
    
    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
            

for i in range(x,110001):
    if using_sqrt(i):
        print(i)
        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


X=int(input())

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