Problem:


Score: 300 points

Problem Statement

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

Notes

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

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

Constraints

 2 \le X \le 10^5 

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X

Output

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

Sample Input 1

20

Sample Output 1

23

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

Sample Input 2

2

Sample Output 2

2

X itself can be a prime number.

Sample Input 3

99992

Sample Output 3

100003



Sample input:
20


Sample output:
23

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
M = 10 ** 6
e = 10 ** 3

# the sieve of Eratosthenes
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))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#%%
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()

# %%
# from atcoder_test import doTest
# doTest("abc149","c",main)

Submission status: Accepted

Solution code:
"""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が２でない偶数ならば素数になりえないのでインクリメント
        X += 1

print(NextPrime(X))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

# Trial-division
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()

Submission status: Accepted

Solution code:

import math

X = int(input())

#xが素数か判定する    
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

Submission status: Accepted

Solution code:
a = int(input())
if a == 2:
    print(2)
    exit()
if a % 2 == 0:
    a += 1
while True:
    count = 0
    for i in range(3,a,2):
        if a % i == 0:
            a += 1
            count += 1
            break
    if count == 0:
        print(a)
        exit()

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt
from fractions import gcd

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas


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

X = intinput()

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

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

while not is_prime(X):
    X += 2

print(X)

Submission status: Accepted

Solution code:
import math

x = int(input())

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

for i in range(x, x+100):
  if is_prime(i):
    print(i)
    exit()

Submission status: Accepted

Solution code:
X=int(input())

i=2
lst=[]
while 1:
    flag=1
    for m in lst:
        if not i%m:
            flag=0
            break
    if flag:
        lst.append(i)
        if i>=X:
            print(i)
            exit()
    i+=1

Submission status: Accepted

Solution code:
x = int(input())

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

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

Submission status: Accepted

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

for num in primes(10**6):
  if num>=n:
    print(num)
    break

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:
from bisect import bisect_left


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]]


x = int(input())
p = primes(100100)
print(p[bisect_left(p, x)])

Submission status: Accepted

Solution code:
import math
import sys

X = int(input())
LIM = 100004 # 100003が素数
num = [0] * LIM
num[0] = 1
num[1] = 1
if X == 2:
    print(X)
else:
    for i in range(2,X):
        if num[i] == 0:
            k = i
            cnt = 1
            while k <= LIM-1:
                num[k] = 1
                cnt += 1
                k = i*cnt
                #print(k)



    S = X
    while num[S] == 1:
        S += 1 

    print(S)

Submission status: Accepted

Solution code:
import os

def main():
    sosu = int(input())
    if sosu == 2:
        print(2)
    else:
        while(checksosu(sosu)):
            sosu += 1
        print(sosu)

def checksosu(num):
    for i in range(3,num,2):
        if num % i == 0:
            return True
    return False
    
if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
x = int(input())

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

    return True
  
while is_prime(x)==False:
  x +=1
    
print(x)

Submission status: Accepted

Solution code:
X = int(raw_input())
 
def check_prime(X):
    import math
    s = int(math.floor(math.sqrt(X)))
    for a in range(2, s+1):
        if X % a == 0:  
            return False
    return True
 
while True:
    if check_prime(X): break
    X += 1
 
print X

Submission status: Accepted

Solution code:
from math import floor,ceil,sqrt,factorial,hypot,log
def read_int(): return int(input())
 
def prime(num):
    for n in range(2,int(sqrt(num))):
        if num % n == 0:
            return False
            break
    return True
  
def solution(K):
    while not prime(K):
        K += 1
    return K
    
K = read_int()
print(solution(K))

Submission status: Accepted

Solution code:
from math import sqrt
from sys import stdin
X = int(stdin.readline().rstrip())

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

    if x < 2 or x % 2 == 0:
        return False

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

while not is_prime(X):
    X += 1

print(X)

Submission status: Accepted

Solution code:

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

    return flag

import math
X = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

import bisect

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]]

primess = primes(100010)
idx = bisect.bisect_left(primess,x)
print(primess[idx])

Submission status: Accepted

Solution code:
X = int(input())

import math

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

while not isPrime(X):
    X += 1

print(X)

Submission status: Accepted

Solution code:
# coding: utf-8
import math
import numpy as np

X = int(input())

sieve = np.ones(100004, dtype=np.bool) * True
sieve[0] = False
sieve[1] = False
limit = math.sqrt(100004)

for i in range(2, int(limit)):
    sieve[i*2::i] = False

primes = np.arange(0, 100004)[sieve]
print(primes[primes >= X][0])

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
	
n = int(input())

X = n

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

Submission status: Accepted

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

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

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

    return True

for x in range(X, X * 2):
    if is_prime(x):
        print(x)
        sys.exit(0)

Submission status: Accepted

Solution code:
import math


def find(X):
    ans = 1
    sq = math.floor(math.sqrt(X))
    for i in range(2, sq + 1):
        if X % i == 0:
            ans = -1
            break
        if i == sq and ans == 1:
            print(X)
            exit()


X = int(input())

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

while True:
    find(X)
    X += 1

Submission status: Accepted

Solution code:
X = int(input())

import math

def is_not_prime(n):
    if n == 1: return True

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

    return False

num = X
while is_not_prime(num):
  num = num+1

print(num)

Submission status: Accepted

Solution code:
x = int(input())
list = [int(i) for i in range(x, 120000)]
for t in list:
    f = 0
    for i in range(2,x//2):
        i = int(i)
        if t % i == 0:
            #print(i)
            f = 1
        if f == 1:
            break
    if f == 0:
        print(t)
        break

Submission status: Accepted

Solution code:
primes = [True] * int(1e6)

for i, v in enumerate(primes):
    if i == 0 or i == 1:
        continue
    if v == True:
        multiple = 2
        while (i)*multiple < len(primes):
            primes[(i)*multiple] = False
            multiple += 1

X = int(input())
for i in range(X, len(primes)):
    if primes[i] == True:
        print(i)
        break

Submission status: Accepted

Solution code:
import math

def isPrime(y):
  if y == 2 or y == 3:
    return True
  for i in range(2, int(math.sqrt(y)) + 2):
    if y % i == 0:
      return False
  return True
x = int(input())
while not isPrime(x):
  x += 1
print(x)

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+10)):
    if is_prime(i)==True:
        print(i)
        break
    else:
        continue

Submission status: Accepted

Solution code:
import math

def isPrime(y):
  if y == 2 or y == 3:
    return True
  for i in range(2, int(math.sqrt(x) + 2)):
    if y % i == 0:
      return False
  return True

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

Submission status: Accepted

Solution code:
def primes(n):
	bool_arr = [True] * (n+1)
	bool_arr[0] = False
	bool_arr[1] = False
	for i in range(2, len(bool_arr)):
		if bool_arr[i]:
			for j in range(i, n//i+1):
				bool_arr[i*j] = False
	return bool_arr

n = 1000000
ans = primes(n)
x = int(input())
for i in range(x, len(ans)):
	if ans[i]:
		print(i)
		break

Submission status: Accepted

Solution code:
def is_prime(x, i):
  if i*i > x:
    return True
  elif x % i == 0:
    return False
  else:
    return is_prime(x, i+1)
  
def gen_prime(x):
  if is_prime(x, 2):
    return x
  else:
    return gen_prime(x+1)
    
if __name__ == "__main__":
  import sys
  sys.setrecursionlimit(10240)
  x = int(input())
  print(gen_prime(x))

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

n=int(input())

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


print (i)

Submission status: Accepted

Solution code:
import math

x = int(input())

for j in range(x,10**6):
    flag = True
    for i in range(2,int(math.sqrt(x))+1):
        if j%i == 0:
            flag = False
    if flag:
        print(j)
        break

Submission status: Accepted

Solution code:
import math

def getPrimes(X):
    primes = []
    limit = math.sqrt(X)
    data = [i + 1 for i in range(1, X)]
    while True:
        p = data[0]
        if limit <= p:
            return primes + data
        primes.append(p)
        data = [d for d in data if d % p != 0]

def getNextPrime(primes, X):
    while True:
        if primes[-1] == X:
            return X
        if any([X % p == 0 for p in primes]):
            X += 1
        else:
            return X
        
X = int(input())
primes = getPrimes(X)
print(getNextPrime(primes, X))

Submission status: Accepted

Solution code:
import math

def getPrimes(X):
    primes = []
    limit = math.sqrt(X)
    data = [i + 1 for i in range(1, X)]
    while True:
        p = data[0]
        if limit <= p:
            return primes + data
        primes.append(p)
        data = [d for d in data if d % p != 0]

def getNextPrime(primes, X):
    while True:
        if any([X % p == 0 for p in primes]):
            if primes[-1] == X:
                return X
            X += 1
        else:
            return X
        
        
X = int(input())
primes = getPrimes(X)
print(getNextPrime(primes, X))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

x=int(input())
table=[True]*200000

for i in range(2,200000):
	if table[i]:
		if i>=x:
			print(i)
			sys.exit()
		for j in range(i*2,200000,i):
			table[j]=False

Submission status: Accepted

Solution code:
def is_prime(n: int) -> bool:
    for i in range(2, n):
        if n % i == 0:
            return False
    return True


def smallest_prime_above_n(n: int) -> int:
    prime_candidate = n
    while True:
        if is_prime(prime_candidate):
            return prime_candidate
        prime_candidate += 1


X = int(input())
print(smallest_prime_above_n(X))

Submission status: Accepted

Solution code:
n = int(input())

while 1:
  count = 0
  for i in range(n+1):
    if i == 0:
      continue
    if n%i == 0:
      count += 1
  if count == 2:
    break
  n += 1
print(n)

Submission status: Accepted

Solution code:
import math
X = int(input())
XX = 2 * X
data = [i for i in range(2,XX+1)]
limit = math.sqrt(XX)
prime = []
while True:
    p = data[0]
    if limit <= p:
        prime = prime + data
        break
    prime.append(p)
    data = [e for e in data if e % p != 0]
lenp = len(prime)
for i in range(lenp):
    if prime[i] >= X:
        print(prime[i])
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

num = int(input())

loop = True
while(loop):
    is_next_prime = trial_division(num)
    if is_next_prime == True:
        print(num)
        loop = False
    num += 1

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
import numpy as np
import sys

X = int(input())
if X == 2 or X == 3:
    print(X)
    sys.exit()

while 1:
    for i in range(2, int(np.sqrt(X) + 1) ):
        if X % i == 0 :
            break

        if i+1 == int(np.sqrt(X) + 1 ):
            print(X)
            sys.exit()
    
    X += 1

Submission status: Accepted

Solution code:
x = int(input())
flag = True

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

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

Solution code:
x = int(input())

import math

while True:
  is_prime = True
  for i in range(2, int(math.sqrt(x))+1):
    if x % i == 0:
      is_prime = False
  if is_prime:
    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**6):
  if is_prime(i):
    print(i)
    exit()

Submission status: Accepted

Solution code:
n = int(input())


while 1:
    prime_dc = 0
    for i in range(2,n):
        if n % i != 0:
            prime_dc += 1
            
    if n-2 == prime_dc:
        break
    
    n += 1

print(n)

Submission status: Accepted

Solution code:
import math

def create_arr(n):
  prime = {i for i in range(2,n)}
  for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
  return prime

def search(x):
  root = math.floor(math.sqrt(float(x)))
  prime_arr = create_arr(root)
  
  for num in prime_arr:
    if int(x) % num == 0:
      return search(int(x)+1)
  print(x)

X = input()
search(X)

Submission status: Accepted

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

from math import sqrt

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
X = int(input())

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

print(X)

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

x = int(input())

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

Submission status: Accepted

Solution code:
import math 
n=int(input())
f=0
if(n==2):
    print(2)
else:
    if(n%2==0):
        n=n+1
    while(f==0):
        k=math.sqrt(n)
        k=math.ceil(n)
        l=0
        for i in range(2,k):
            if(n%i==0):
                break
            else:
                l=l+1
        if(l==k-2):
            f=1
            print(n)
        else: 
            n=n+2

Submission status: Accepted

Solution code:
from math import sqrt

N = 10 ** 6

p = [True] * (N + 1)
p[0] = False
p[1] = False
n = int(sqrt(N) + 1)
for j in range(4, N + 1, 2):
  p[j] = False
for i in range(3, n + 1, 2):
  if p[i]:
    for j in range(i + i, N + 1, i):
      p[j] = False


X = int(input())
for i in range(X, N + 1):
    if p[i]:
        print(i)
        break

Submission status: Accepted

Solution code:
def prime(n):
  prime_table = [2]
  for i in range(3,n+1):
    f = 1
    for j in prime_table[:bisect.bisect_right(prime_table,int(i**0.5))]:
      if i % j == 0:
        f = 0
        break
    if f:
      prime_table.append(i)
  return prime_table

import bisect
x = int(input())
pt = prime(5*10**5)
print(pt[bisect.bisect_left(pt,x)])

Submission status: Accepted

Solution code:
import math

def prime(num):
    count = 0
    for i in range(2, math.floor(math.sqrt(num)) + 1):
        if num == 2:
            break
        if i % 2 == 0 and i != 2:
            continue
        if X % i == 0:
            count += 1

    if count == 0:
        return True
    else:
        return False


X = int(input())

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

Submission status: Accepted

Solution code:
int_a = int(input())
root_a = int(int_a ** 0.5)
if int_a <= 3:
    print(int_a)
else:
    for b in range(int_a, int_a + 1000):
        flag = True
        for c in range(2, root_a + 2):
            if b % c == 0:
                flag = False
                break
        if flag:
            print(b)
            break

Submission status: Accepted

Solution code:
s = input().split()
a = int(s[0])-1
t=0
def hantei(x):
    i=2
    while i*i < a:
        if x % i == 0:
            return 0
        i += 1
    return 1
while t<1:
    a += 1
    t=hantei(a)
print(a)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def is_prime(n):
    for p in range(2,n):
        if n % p ==0:
            return True

n =int(input())
m=n
while m <10**7:
    if is_prime(m):
        m +=1
    else:
        print(m)
        break

Submission status: Accepted

Solution code:
##C
X = int(input())
##素数かどうか判定
from math import sqrt
def is_prime(n):
    for i in range(2, int(sqrt(n))):
        if n % i == 0:
            return False
    else:
        return True

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

print(X)

Submission status: Accepted

Solution code:
s = int(input())
if s <= 2:
  print(2)
  exit()
elif s <= 3:
  print(3)
  exit()
elif s <= 5:
  print(5)
  exit()

while True:
  for i in range(2,s // 2):
    if s % i == 0:
      break
  if i == s //2 -1:
    print(s)
    exit()
  s += 1

Submission status: Accepted

Solution code:

inputA = int(input())

flag = 0
for count in range(inputA,300000):

    for mod in range(2,200000):
        if count % mod == 0:
            flag = mod
            break
        mod += 1
    if count == flag:
        print(count)
        break
    elif flag == 0:
        print(inputA)
    else:
        count += 1

Submission status: Accepted

Solution code:
X = int(input())
if X > 2 and not X % 2: X += 1

while True:
    i = 3

    f = True
    while i ** 2 <= X:
        if not X % i:
            f = False
            break
        i += 2
        
    if f and X > 1: break

    X += 2
    
print(X)

Submission status: Accepted

Solution code:
x = int(input())

def get_is_prime(x):
  if x <= 1:
    return False
  for i in range(2, x):
    if i ** 2 >= x:
      break
    if x % i == 0:
      return False
  return True

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

Submission status: Accepted

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

f3 = False
while f3 != True:
    if n1 == 1:
        break
    if n1 == 2:
        break
    for i2 in range(1, int(math.sqrt(n1))):
        if n1 % (i2 + 1) == 0:
            n1 += 1
            break
        elif i2 + 1 == int(math.sqrt(n1)):
            f3 = True
            break
print(n1)

Submission status: Accepted

Solution code:
s = int(input())
if s <= 2:
  print(2)
  exit()
elif s <= 3:
  print(3)
  exit()
elif s <= 5:
  print(5)
  exit()

while True:
  for i in range(2,s // 2):
    if s % i == 0:
      break
  if i == s //2 -1:
    print(s)
    exit()
  s += 1

"""
prime_data = [2,3,5]

for i in range(3,10**5):
  tmp = int(i//2)
  for j in range(2,tmp):
    if i % j == 0:
      break
    if j == tmp-1:
      prime_data.append(i)
print(prime_data)
"""

Submission status: Accepted

Solution code:
x = int(input())
def search(y):
    for i in range(2, y//2):
        if y % i == 0:
            break
    else:
        return True
    
    return False

while 1:
    ans = search(x)
    if ans:
        print(x)
        break
    x+=1

Submission status: Accepted

Solution code:
from math import sqrt

X = int(input())
not_finded = True
X = X+1 if (X%2 == 0) and X != 2 else X 

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

while (not_finded):
    if is_prime(X):
        not_finded = False
        print(X)
    else:
        X += 2

Submission status: Accepted

Solution code:
def prime(x):
  max_x = (x ** (1 / 2)) // 1
  ans = 1
  for i in range(2, int(max_x) + 1):
    if x % i == 0:
      ans = 0
  return ans

if __name__ == "__main__":
  n = int(input())
  ans = 0
  while ans == 0:
    ans = prime(n)
    if ans == 0:
      n += 1
  print(n)

Submission status: Accepted

Solution code:
x = int(input())

lp = [0] * 1000005
for i in range(2, 100005):
    if lp[i] == 1:
        continue
    if x <= i:
        print(i)
        break

    k = i*i
    while k < 1000005:
        lp[k] = 1
        k += i

Submission status: Accepted

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

if X == 1 or X==2:
  print(2)
  sys.exit()

while(True):
  flg = True
  if X%2 == 0:
    X += 1
    continue
    
  for i in range(3,X):
    if X%i == 0:
      flg = False
      
  if flg is True:
    print(X)
    sys.exit()

  X += 2

Submission status: Accepted

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

if __name__ == "__main__":
    n = int(input())
    while True:
        if isPrime(n):
            print(n)
            break
        else:
            n += 1

Submission status: Accepted

Solution code:
x = int(input())
m = 2 * x

sieve = [True for _ in range(m+1)]

p = 2
i = 2
while True:
    if p * p >= m:
        break
    while p * i <= m:
        sieve[p * i] = False
        i += 1
    p += 1
    while not sieve[p]:
        p += 1
    i = 2

for i in range(x, m):
    if sieve[i]:
        print(i)
        break

Submission status: Accepted

Solution code:
def is_not_primary(x):
    bln = False
    for i in range(2, x):
        if x % i == 0:
            bln = True
        else:
            continue
    return bln

def main():

    X = int(input())
    start = X
    while is_not_primary(start):
        start += 1
    else:
        print(start)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x = int(input())

def sosu(x):
  for i in range(2,x-1):
    if x % i == 0:
      return False
  return True

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

print(x)