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
MAX_X = 10**5 + 1000

pt = [True]*MAX_X
pt[0], pt[1] = False, False

for i in range(2, int(math.sqrt(MAX_X))+1):
    for j in range(2*i, MAX_X, i):
       pt[j] = False

primes = [ idx for idx, num in enumerate(pt) if num == True]

X = int(input())

for prime in primes:
    if X <= prime:
        print prime
        break

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

n=int(input())

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

Submission status: Accepted

Solution code:
x = int(input())
max_i = 10**6
nums = 10**6
num = {i:True for i in range(2,10**6+1)}
i = 2
while i < nums:
    if num[i] == True:
        j = i
        k = j
        while j * k  <= nums:
            num[j*k] = False
            k += 1    
    i += 1
primes = [k for k,v in num.items() if v == True]
primes = [i for i in primes if i >=x]
# idx = primes.index(x)
# print(max(primes[idx:]))
print(min(primes))

Submission status: Accepted

Solution code:
a=int(input())
s=set()
m=10**5+4
for i in range(2,m):
    if i not in s:
        if i>=a:
            print(i)
            break
        for j in range(i*2,m,i):
            s.add(j)

Submission status: Accepted

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
import math


def isp(n):
    if n <= 1:
        return False

    if n == 2:
        return True

    if n % 2 == 0:
        return False

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

    return True

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

while True:
  if a(x):
    print(x)
    quit()
  x+=1

Submission status: Accepted

Solution code:
import sys
import math

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

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

    return True

x = int(input())

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

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

i=0
flag = 0
while flag == 0 : 
   if is_prime( i+x ) : 
      print( i+x )
      flag = 1 
   else :
      i += 1

Submission status: Accepted

Solution code:
import math
X = int(input())
if X < 4:
    print(X)
    exit()
n = X
ans = 0
while 1:
    for i in range(2, 1+int(math.sqrt(n))):
        if n % i == 0:
            n += 1
            break
        if (i == int(math.sqrt(n))):
            ans = n
    if ans != 0:
        print(n)
        exit()

Submission status: Accepted

Solution code:
import sys
#import numpy as np
stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

X = ri()
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]]

l = set(primes(10**6))

while True:
    if X in l:
        print(X)
        exit()
    X += 1

Submission status: Accepted

Solution code:
def Eratosthenes(n):
    li = [i for i in range(2,n+1)]
    judge = [True for i in range(n+1)]
    ans = []
 
    for i in range(2,n+1):
        if judge[i] == True:
            for j in range(i*2,n+1,i):
                judge[j] = False
            ans.append(i)
    return ans
 
x = int(input())
l = Eratosthenes(10 ** 6)
for i in l:
    if i >= x:
        print(i)
        exit()

Submission status: Accepted

Solution code:
X = int(input())

import math

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

	# nの平方根まで計算する
	m = math.floor(math.sqrt(n)) + 1
	for p in range(3, m, 2):
			if n % p == 0:
				return False
	return True

ans = X
while not (isPrime(ans)):
	ans+=1
print(ans)

Submission status: Accepted

Solution code:
import bisect
import sys
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(100):
    if is_prime(x) == 1:
        print(x)
        sys.exit()
    x += 1

Submission status: Accepted

Solution code:
x = int(input())

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

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

table = sieve(10**5 + 100)

for i in table:
    if i >= x:
        print(i)
        exit()

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
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 True:
    if is_prime(x)==True:
        print(x)
        break
    else:
        x+=1

Submission status: Accepted

Solution code:
import numpy as np


def searchPrimeNumber(N):
    N = N + 1
    is_prime = np.ones((N, ), dtype=bool)
    is_prime[:2] = 0
    N_max = int(np.sqrt(N))
    for j in range(2, N_max + 1):
        if (is_prime[j]):
            is_prime[j * j::j] = False
    prime = np.arange(N)[is_prime]
    return prime


def main():
    X = int(input())
    p = searchPrimeNumber(10**5 + 10)

    p = p[p >= X]
    print(p[0])


main()

Submission status: Accepted

Solution code:
N = int(input())
flag = True
while flag:
  if N==2 or N==3:
    print(N)
    flag=False
    break
  n = N**0.5
  for i in range(2,int(n//1)):
    if N%i==0:
      break
    if i==n//1-1:
      flag=False
      print(N)
      break
  N+=1

Submission status: Accepted

Solution code:
from math import sqrt, floor

X = int(input())

def isPrimeNum(num):
    if num == 2:
        return True
    
    for i in range(3, floor(sqrt(num)), 2):
        if num % i == 0:
            return False
    return True



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

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

for kazu in range(X, 100004, 2):
    if isPrimeNum(kazu):
        print(kazu)
        exit()

Submission status: Accepted

Solution code:
import math
def is_prime(number):
    flag = True
    for x in range(2, int(math.sqrt(number))+1):
        if number%x==0:
            flag=False
    return flag
num = int(input())
while not(is_prime(num)):
    num+=1
print(num)

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())

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

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

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

print(X)

Submission status: Accepted

Solution code:
x=int(input())
def primeddx(x):
    for i in range(2,x):
        if x%i==0:
            return False
    return True

while not primeddx(x):
    x+=1
print(x)

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

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

x=int(input())
if x==2:
  print(x)
else:
  x=x//2*2+1
  while True:
    if is_prime(x)==True:
      print(x)
      exit()
    x+=2

Submission status: Accepted

Solution code:
X = int(input())

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

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

Submission status: Accepted

Solution code:

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


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


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

Submission status: Accepted

Solution code:
X = int(input())


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


l = primes(10 ** 5 + 10000)
for i in l:
    if i >= X:
        print(i)
        exit()

Submission status: Accepted

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

X = int(input())
for n in range(X, 1000000):
    if isPrime(n):
        print(n)
        break

Submission status: Accepted

Solution code:
X=int(input())

#引数nが素数かどうかを判定
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
import sys
for i in range(X,X+10**5):
    if is_prime(i):
        print(i)
        sys.exit()

Submission status: Accepted

Solution code:
def run(x):
    n = 10**5 + 1000
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    for i in range(x, n):
        if is_prime[i]:
            ans = i
            break
    return ans


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
def isPrime(n):
    i = 2
    while i**2 <= n:
        if n%i == 0:
            return False
        i += 1
    return n != 1
while ans == 0:
    if isPrime(X):
        ans = X
    else:
        X += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from bisect import bisect_left
from sys import stdin


def primes235(limit):
    yield 2; yield 3; yield 5
    if limit < 7: return
    modPrms = [7,11,13,17,19,23,29,31]
    gaps = [4,2,4,2,4,6,2,6,4,2,4,2,4,6,2,6]
    ndxs = [0,0,0,0,1,1,2,2,2,2,3,3,4,4,4,4,5,5,5,5,5,5,6,6,7,7,7,7,7,7]
    lmtbf = (limit + 23) // 30 * 8 - 1
    lmtsqrt = (int(limit ** 0.5) - 7)
    lmtsqrt = lmtsqrt // 30 * 8 + ndxs[lmtsqrt % 30]
    buf = [True] * (lmtbf + 1)
    for i in range(lmtsqrt + 1):
        if buf[i]:
            ci = i & 7; p = 30 * (i >> 3) + modPrms[ci]
            s = p * p - 7; p8 = p << 3
            for j in range(8):
                c = s // 30 * 8 + ndxs[s % 30]
                buf[c::p8] = [False] * ((lmtbf - c) // p8 + 1)
                s += p * gaps[ci]; ci += 1
    for i in range(lmtbf - 6 + (ndxs[(limit - 7) % 30])): # adjust for extras
        if buf[i]: yield (30 * (i >> 3) + modPrms[i & 7])


def main():
    input = lambda: stdin.readline()[:-1]
    X = int(input())

    p = list(primes235(100003))
    i = bisect_left(p, X)
    print(p[i])


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())

i = 0
while True:
    if is_prime(x+i) == True:
        break
    else:
        i +=1

print(x+i)

Submission status: Accepted

Solution code:
import math


def seachPrimeNum(N):
    max = int(math.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


def isPrime(n, prime_numbers):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    m = math.floor(math.sqrt(n))
    for p in prime_numbers:
        if n % p == 0:
            return False
        if p > m:
            # 素数がnの平方根を超えたら終了
            break
    return True


def main():
    A = int(input())
    primeNum = seachPrimeNum(A)
    while True:
        if isPrime(A, primeNum) is True:
            print(A)
            break
        A += 1


if __name__ == "__main__":
    main()

Submission status: Accepted

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


def solve(X: int):
    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


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

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
def is_prime(num):
    root = math.ceil(math.sqrt(num))
    for i in range(2, root):
        if num % i == 0:
            return False
    return True

N = int(input())
while True:
    if is_prime(N):
        print(N)
        exit(0)
    N += 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
n=int(input())
for i in range(10000):
    if is_prime(n)==True:
        print(n)
        break
    n=n+1

Submission status: Accepted

Solution code:
import math

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

  # nの平方根まで計算する
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True

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

    while(True):

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

Submission status: Accepted

Solution code:
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    def SieveOfEratosthenes(n):
        prime = [True for i in range(n + 1)]
        p = 2
        while (p * p <= n):
            if (prime[p] == True):
                for i in range(p * 2, n + 1, p):
                    prime[i] = False
            p += 1
        prime[0]= False
        prime[1]= False
        l=[]
        for i in range(n+1):
            if prime[i]:
                l.append(i)
        return l
    l=SieveOfEratosthenes(100006)
    # print(l)
    x=I()
    for i in l:
        if i>=x:
            print(i)
            break



if __name__ == "__main__":
    main()

Submission status: Accepted

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

X = int(input())
ans = X
n = math.sqrt(X)
for i in range(int(n)):
  if isPrime(ans):
    break
  else:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

def fanc(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

def furui(n):
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]:
        	fanc(s, x)
    return [i for i in range(0,n) if s[i] and i > 1]

list = furui(10**6)
for i in range(len(list)):
	if list[i] >= x:
		print(list[i])
		exit(0)

Submission status: Accepted

Solution code:
from math import sqrt

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

# print('input >>')
X = int(input())

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

# print('-----output-----')

Submission status: Accepted

Solution code:
def solve():
    X = int(input())
    while len(prime_factorize(X)) != 1:
        X += 1
    print(X)

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 __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
x = int(input())
def prime(n):
    if n == 1:
        return 0
    elif n == 2:
        return 2
    else:
        if n%2 == 0:
            return 0
        for i in range(3,int(n**0.5)+1):
            if n%i == 0:
                return 0
        return n
for i in range(x,2*10**5+1):
    if prime(i):
        print(i)
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
a = int(input())

def check(s):
    fl = True
    for i in range(2,s):
        if s % i == 0:
            fl = False
    return(fl)
    
if check(a):
    print(a)
else:
    while not(check(a)):
        a+=1
    print(a)

Submission status: Accepted

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

x=int(input())
i=0
while is_prime(x+i)==False:
  i+=1
print(x+i)

Submission status: Accepted

Solution code:
import math

X = int(input())

#https://qiita.com/neko_the_shadow/items/4ebad619564a48f5a97f
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

primenums = primes(100004)

for primenum in primenums:
    if X <= primenum:
        print(primenum)
        break

Submission status: Accepted

Solution code:
import numpy

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

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

    return True


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

Submission status: Accepted

Solution code:
# 2019/12/29

from bisect import bisect_left

x=int(input())

def sieve(n):
    end=int(pow(n,0.5))+1
    is_prime=[True]*(n+1)
    is_prime[0]=False
    is_prime[1]=False

    for i in range(2,end+1):
        if not is_prime[i]:continue
        for j in range(i*2,n+1,i):
        #for j in range(i*(i|0),n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]

primes=sieve(10**5+10)
ans=bisect_left(primes,x)
print(primes[ans])

Submission status: Accepted

Solution code:
#C
X = int(input())
while True:
    root_X = X ** 0.5
    found_prime = True
    for i in range(2, int(root_X)+1):
        if X % i == 0:
            X += 1
            found_prime = False
            break
    if found_prime == True:
        print(X)
        break

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())
i=0
while True:
  i+=1
  if is_prime(i) and i>=X:
    print(i)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=2*10**5

import math 
L=math.floor(math.sqrt(x))# 平方根を求める

Primelist=[i for i in range(x+1)]
Primelist[1]=0# 1は素数でないので0にする.
 
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0

Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0]

import bisect
X=int(input())

k=bisect.bisect_left(Primes,X)
print(Primes[k])

Submission status: Accepted

Solution code:
import math

number = 123


def trial_division(target):
    dest = int(math.sqrt(target))

    for i in range(2, dest):
        if target % i == 0:
            return False
    return True

n = int(input())
while True:
    if(trial_division(n)):
        print(n)
        exit()
    n+=1

Submission status: Accepted

Solution code:
import math

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

    # nの平方根まで計算する
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
    return True

X = int(input())

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

Submission status: Accepted

Solution code:
import sys
from pprint import pprint
import math

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

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

    return True

def solve(x):
    for i in range(x, 10**6):
        if is_prime(i):
            print(i)
            return

if __name__ == '__main__':
    x = int(sys.stdin.readline().strip())
    solve(x)

Submission status: Accepted

Solution code:
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
while not is_prime(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

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

    while True:
        if is_prime(X):
            return X
        X = X + 1

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
X = int(input())
n = 100003
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
Y = [i for i in primes if i>=X]
print(Y[0])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def furui(n):
  if n <= 1:
    return []

  primes = []
  target = [i for i in range(2, n+1)]

  while(True):
    if target[0] ** 2 > n:
      break
    primes.append(target[0])
    target = list(filter(lambda x: (x % primes[-1]) != 0, target))
    # print(target)

  primes.extend(target)
  return primes

primes = furui(10**5 + 10)

X = int(input())
for p in primes:
  if p >= X:
    ans = p
    break

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
import sys

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

X = int(input())
if X == 2:
    print(2)
    sys.exit()
for x in range(X,2*(10**5)):
    if isprime(x):
        print(x)
        sys.exit()

Submission status: Accepted

Solution code:
X = int(input())

if X == 2:
    ans = X
else:
    d = X + 1 if X % 2 == 0 else X
    while True:
        i = 3
        while i * i <= d:
            if d % i == 0:
                break
            i += 2
        else:
            ans = d
            break
        d += 2

print(ans)

Submission status: Accepted

Solution code:
X = int(input())


def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    m = 3
    while m ** 2 <= n:
        if n % m == 0:
            return False
        m += 2
    return True


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

Submission status: Accepted

Solution code:

X = int(input())
q = [2]

now = 3

while q[-1] < X:

    flag = True
    for i in q:
        if now % i == 0:
            flag = False
            break

    if flag:
        q.append(now)

    now += 2

print (q[-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, 100004):
    if is_prime(i):
        break
    
print(i)

Submission status: Accepted

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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def p_c():
    n = int(input())

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

    li = primes(n*2)

    for i in range(n, n*2):
        if i in li:
            print(i)
            exit()
            
p_c()

Submission status: Accepted

Solution code:

x = int(input())

sqx = int((2*x)**(1/2)) + 30
test = [1]*min(sqx,10000)
for i in range(2,min(sqx,10000)):
    for j in range(min(sqx,10000)):
        if (x+j)%i==0 and x+j>i:
            test[j] = 0
for i in range(min(sqx,10000)):
    if test[i]:
        print(x+i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 素因数, ...]の1次元リスト"""
"""12 => [2, 2, 3]"""
def factorizeFlat(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                arr.append(i)
                temp //= i

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr


x = int(input())
n = len(factorizeFlat(x))
while n > 1:
    x += 1
    n = len(factorizeFlat(x))
print(x)

Submission status: Accepted

Solution code:
#coding:utf-8

a = int(input())

def chk_prime(n):
    i = 2
    is_prime = True
    while i <= n ** (1/2):
        if n % i == 0:
            is_prime = False
            break
        i += 1
    return is_prime
        
        
while chk_prime(a) == False:
    a += 1
print(a)

Submission status: Accepted

Solution code:
x = int(input())

maxi = int(1e5) + 100
prime = [True for _ in range(maxi + 1)]

for num in range(3, maxi + 1):
    i = 2 * num
    while i <= maxi:
        prime[i] = False
        i += num

while True:
    if prime[x] is True:
        print(x)
        exit(0)
    else:
        x += 1

Submission status: Accepted

Solution code:
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 1:
  if is_prime(x):print(x);exit()
  x+=1

Submission status: Accepted

Solution code:
x = int(input())

def sieve(n):
    prime = [True] * (n + 1)
    i = 2
    while i * i <= n:
        if prime[i]:
            for j in range(i * i, n + 1, i):
                prime[j] = False
        i += 1
    return [i for i in range(2, n + 1) if prime[i]]

primes = sieve(10 ** 5 + 10)
for p in primes:
    if p >= x:
        print(p)
        exit()
raise Exception