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:
from math import floor, sqrt

x = int(input())

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

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

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

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 is_prime(x) == False:
    x += 1

print(x)

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 is_prime(x) == False:
    x += 1

print(x)

Submission status: Accepted

Solution code:
from math import sqrt


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

    sqrtNum = sqrt(num)
    for i in range(3, int(sqrtNum) + 1, 2):
        if num % i == 0:
            return False

    return True


if __name__ == "__main__":
    x = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

import math

serach_number = 100


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

print(X)

Submission status: Accepted

Solution code:
X = int(input())


j = True
s = []
while j == True:
    for p in range(2, X):
        if X % p == 0:
            s.append(False)
        else:
            s.append(True)

    if all(s) == True:
        print(X)
        exit()
    else:
        X += 1
        s = []

Submission status: Accepted

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

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())
for i in range(x, 2*x+1):
    flg = is_prime(i)
    if flg == True:
        ans = i 
        break
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
A=10**6
pn=[2]
for L in range(3, A, 2):
    if x==2:
        print(2)
        exit()
    if all(L % L2 != 0 for L2 in pn):
        pn.append(L)
        if L>=x:
            k=L
            break
print(k)

Submission status: Accepted

Solution code:
import sys

X = int(input())

def prime(x):

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

while 1:
    if True==prime(X):
        print(X)
        sys.exit()
    X = X + 1

Submission status: Accepted

Solution code:
x = int(input())
max_x = 100003
f = [0 for _ in range(max_x+1)]
f[0] = -1
f[1] = -1
primes = []
for i in range(2, max_x+1):
    if f[i]:
        continue
    primes.append(i)
    f[i] = i
    for j in range(i*i, max_x+1, i):
        if f[j] == 0:
            f[j] = i

for p in primes:
    if x <= p:
        print(p)
        break

Submission status: Accepted

Solution code:
import math
import bisect
prime = [2]
max = 10 ** 5 + 7
limit = int(math.sqrt(max))
data = [i + 1 for i in range(2, max, 2)]

while limit > data[0]:
    prime.append(data[0])
    data = [j for j in data if j % data[0] != 0]
prime = prime + data

x = int(input())
ans = bisect.bisect_left(prime, x)
print(prime[ans])

Submission status: Accepted

Solution code:
def is_prime(k):
    import math
    if k % 2 == 0 and k != 2:
        return False
    for divisor in range(2, math.floor(math.sqrt(k))+1):
        if k % divisor == 0:
            return False
    return True
import sys
x = int(input())
while True:
    if is_prime(x):
        print(x)
        sys.exit()
    x+=1

Submission status: Accepted

Solution code:
def is_prime(n):
    if n<2: return False
    for p in range(2, n):
        if n%p==0:
            return False
    return True
x=int(input())
while not is_prime(x):
    x+=1
print(x)

Submission status: Accepted

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

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

max = 10**9

for i in range(x, max):
    if is_prime(i):
        print(i)
        break

Submission status: Accepted

Solution code:

import math

X = int(input())
  
#素数判定
#Nが素数か True/False で返す
#O(√N)
def is_prime(N):
    if N == 1:
        return False
    for i in range(2,N+1):
        #調べるのはNの1/2乗まででよい
        if i * i > N:
            break
        #割り切れたら素数じゃない
        if N % i == 0:
            return False
    
    return True

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

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, n + 1):
        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())
l=primes(100010)
for i in range(len(l)):
  if l[i]>=x:
    print(l[i])
    exit()

Submission status: Accepted

Solution code:
X = int(input())

while True:
    x = int(X ** 0.5)
    b = True #Xが素数
    for i in range(3, x, 2):
        if X % 2 == 0 or X % i == 0:
            b = False
            break
    if b == False:
        X += 1
    else:
        break
print(X)

Submission status: Accepted

Solution code:
x = int(input())

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

flag = True
x -= 1
while flag:
    x += 1
    i = 2
    while flag:
        if x % i == 0:
            break
        elif i ** 2 >= x:
            flag = False
        else:
            i += 1
print(x)

Submission status: Accepted

Solution code:
import math

ip = int(input())

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

primes = [2]
for i in range(3, 100001, 2):
    for p in primes:
        if i % p == 0:
            break
    else:
        primes.append(i)

primes.append(100003)
primes = primes[::-1]

for i in range(len(primes)):
    if primes[i] < ip:
        print(primes[i - 1])
        exit()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
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

def solve(X: int):
    for i in range(X,10**16):
        if isPrime(i):
            print(i)
            exit()
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
m = n
if n in [2,3]:
  print(n)
  exit()
while True:
  for i in range(2,int(m**0.5)+1):
    if m %i == 0:
      break
    elif i > int(m**0.5)-1:
      print(m)
      exit()
  m += 1

Submission status: Accepted

Solution code:
n = int(input())

p = [0]*1000001
for i in range(2,n):
    if(p[i] == 0):
        for j in range(i,1000001,i):
            p[j] = 1

result = 0
for i in range(n,1000001):
    if(p[i] == 0):
        result = i
        break

print(result)

Submission status: Accepted

Solution code:
num = int(input())

def factors(x):
  a = []
  for i in range(1, x + 1):
      if x % i == 0:
          a.append(i)
  return a

f = (factors(num))

if (len(f) != 2): 
  while (len(f) != 2): 
    num += 1
    f = factors(num)
  print (num)
else: 
  print (num)

Submission status: Accepted

Solution code:
X = int(input())
x = X
X *= 2
work = [True for i in range(X)]
for i in range(2, int(X**0.5)+1):
    if not work[i]:
        continue
    for j in range(i*2, len(work), i):
        work[j] = False
prime = []
for i in range(2, len(work)):
    if work[i] and i>=x:
        result = i
        break
print(result)

Submission status: Accepted

Solution code:
import sys
from bisect import bisect_left as bi_l

def sieve_of_eratosthenes(n=5 * 10 ** 6):
  sieve = [1] * (n + 1); sieve[0] = sieve[1] = 0
  for i in range(2, int(n ** 0.5) + 1):
    if not sieve[i]: continue
    for j in range(i * 2, n + 1, i): sieve[j] = 0
  prime_numbers = [i for i in range(2, n + 1) if sieve[i]]
  return sieve, prime_numbers

is_prime, prime_numbers = sieve_of_eratosthenes()

def prime_factorize(n):
  res = dict()
  if n < 2: return res
  border = int(n ** 0.5)
  for p in prime_numbers:
    if p > border: break
    while n % p == 0: res[p] = res.get(p, 0) + 1; n //= p
    if n == 1: return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = dict()
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items(): res[p] = res.get(p, 0) + c
  return res

x = int(sys.stdin.readline().rstrip())

def main():
    i = bi_l(prime_numbers, x)
    print(prime_numbers[i])

if __name__ ==  '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

import numpy as np
def sieve_of_eratosthenes(n=5 * 10 ** 7):
  sieve = np.ones(n + 1); sieve[:2] = 0
  for i in range(2, int(np.sqrt(n)) + 1):
    if sieve[i]: sieve[i*2::i] = 0
  return sieve, np.flatnonzero(sieve)

is_prime, prime_numbers = sieve_of_eratosthenes()

def prime_factorize(n):
  res = dict()
  if n < 2: return res
  border = int(n ** 0.5)
  for p in prime_numbers:
    if p > border: break
    while n % p == 0: res[p] = res.get(p, 0) + 1; n //= p
    if n == 1: return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = dict()
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items(): res[p] = res.get(p, 0) + c
  return res

x = int(sys.stdin.readline().rstrip())

def main():
    i = np.searchsorted(prime_numbers, x, side='left')
    print(prime_numbers[i])

if __name__ ==  '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

import numpy as np
def sieve_of_eratosthenes(n=10 ** 7):
  sieve = np.ones(n + 1); sieve[:2] = 0
  for i in range(2, int(np.sqrt(n)) + 1):
    if sieve[i]: sieve[i*2::i] = 0
  return sieve, np.flatnonzero(sieve)

is_prime, prime_numbers = sieve_of_eratosthenes()

def prime_factorize(n):
  res = dict()
  if n < 2: return res
  border = int(n ** 0.5)
  for p in prime_numbers:
    if p > border: break
    while n % p == 0: res[p] = res.get(p, 0) + 1; n //= p
    if n == 1: return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = dict()
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items(): res[p] = res.get(p, 0) + c
  return res

x = int(sys.stdin.readline().rstrip())

def main():
    i = np.searchsorted(prime_numbers, x, side='left')
    print(prime_numbers[i])

if __name__ ==  '__main__':
    main()

Submission status: Accepted

Solution code:
n = 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 is_prime(n) is False:
    n+=1
print(n)

Submission status: Accepted

Solution code:
import math
x = int(input())
for i in range(x, 100004):
    flag = True
    for j in range(2, math.floor(math.sqrt(i)+1)):
        if i % j == 0:
            flag = False
            break
    if flag:
        print(i)
        exit(0)

Submission status: Accepted

Solution code:
import math

x = int(input())
a = 1

while a:
  b = 0
  for i in range(2, int(math.sqrt(x))+1):
    if x % i == 0:
      b += 1
      x += 1
      break
  if b == 0:
    print(x)
    exit()

Submission status: Accepted

Solution code:
x=int(input())
count=0
for i in range(x,100000000):
  for j in range(2,100000):
    if j!=i:
      if i%j==0:
        count+=1
        break
  if count==0:
    print(i)
    exit()
  else:
    count=0
    continue

Submission status: Accepted

Solution code:
X = int(input())

def make_primes_list(n):
    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)
    return primes

P = make_primes_list(100005)

for x in range(X,100005):
    if x in P:
        print(x)
        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


MAX_NUM = 1000000000  # 1_000_000_000
X = int(input())

for num in range(X, MAX_NUM):
    if is_prime(num):
        print(num)
        break

Submission status: Accepted

Solution code:
import math
x = int(input())
'''
逐次探索だとTLE
def check():
    prime_li = [2]
    if x==2:
        return 2
    for i in range(3,x+1,2):
        if all(i%p!=0 for p in prime_li):
            prime_li.append(i)

    for i in range(x+1,10**6):
        if all(i%p!=0 for p in prime_li):
            return i
'''
#エラトステネスの篩でxまでの素数を求める
def get_primeli(x):
    prime_li=[]
    serch_li=list(range(2,x+1))
    while True:
        if serch_li[0]>math.sqrt(x):
            prime_li.extend(serch_li)
            break
        else:
            y = serch_li.pop(0)
            prime_li.append(y)
            serch_li = [n for n in serch_li if n%y!=0]
    return prime_li

prime_li = get_primeli(x)

#x以上の素数を探索
for n in range(x,10**6):
    if n in prime_li:
        print(n)
        break
    if all(n%p!=0 for p in prime_li):
        print(n)
        break

Submission status: Accepted

Solution code:
def divisor(x):
    div=[]
    for i in range(1,int(x**(1/2))+1):
        if x%i==0:
            div.append(i)
            if i!=x//i:
                div.append(x//i)
    return sorted(div)


X=int(input())
while True:
    if len(divisor(X))==2:
        break
    else:
        X+=1
print(X)

Submission status: Accepted

Solution code:
#定数
#2≦x≦10^5
x = int(input())

f = False   #flag    
x = x - 1
#素数がになるまでインクリメントを続ける
while f == False:
    x += 1
    #素数判定
    def judge_prime_num(a:int)->bool:   #O(√N)
        m = int(a**(1/2)+1)
        for i in range(2, m):
            if a % i == 0:
                return False
            else:
                pass
        return True
    f = judge_prime_num(x)

#答えの出力
print(x)

Submission status: Accepted

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

def 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

for j in range(x,2*x):
    if prime(j)==True:
        print(j)
        sys.exit()

Submission status: Accepted

Solution code:
import math

X = int(input())

judge = True
while judge:
    flg = 0
    for i in range(2,math.ceil(X/2)):
        if X % i == 0:
            flg = 1
            break
    if flg == 1:
        X +=1
    else:
        judge = False

print(X)

Submission status: Accepted

Solution code:
import math

X = int(input())

judge = True
while judge:
    flg = 0
    for i in range(2,math.floor(X/2)):
        if X % i == 0:
            flg = 1
            break
    if flg == 1:
        X +=1
    else:
        judge = False

print(X)

Submission status: Accepted

Solution code:
import math

X = int(input())

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

    return True

while not check(X):
    X += 1

print(X)

Submission status: Accepted

Solution code:
import math

X = int(input())

def era(n):
    O = [i + 2 for i in range(n-1)]
    P = []
    for i in range(int(math.sqrt(n))):
        P.append(O[0])
        O = [o for o in O if o % P[-1] != 0]
    for o in O:
        P.append(o)
    return P

P = era(2*X)
for i in range(len(P)):
    if X <= P[i]:
        print(P[i])
        break

Submission status: Accepted

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

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

while prime(X):
    X += 1
print(X)

Submission status: Accepted

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

def prime(x):
    if x == 2:
        return True
    elif x % 2 == 0:
        return False
    elif x > 2:
        for i in range(3, math.floor(math.sqrt(x))+1,2):
            if x % i == 0:
                return False
        return True
while prime(x) != True :
    x += 1
print(x)

Submission status: Accepted

Solution code:
import math
x = int(input())
def prime_get():
    if x <= 1:
        return []
    prime = [2]
    limit = int(math.sqrt(x))
    data = [i+1 for i in range(2,100004,2)]

    while limit >= data[0]:
        prime.append(data[0])
        data = [j for j in data if j % data[0] != 0]
    return prime+data

ans = prime_get()
ans = [i for i in ans if i >= x]
print(ans[0])

Submission status: Accepted

Solution code:
# solution
import io
import math

data = int(input())

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

for i in range(data, data+100):
  if primos(i):
    print(i)
    exit()

Submission status: Accepted

Solution code:
def eratosthenes(n):
    l = [i for i in range(2, n + 1)]
    for i in range(2, int(n ** 0.5) + 1):
        l = [j for j in l if j % i != 0 or i == j]
    return l

x = int(input())
l = eratosthenes(2 * (10 ** 5))
for i in l:
    if x <= i:
        print(i)
        exit()

Submission status: Accepted

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

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

while isprime(X) is not True:
    X += 1

print(X)

Submission status: Accepted

Solution code:
import bisect
x = int(input())
def eratosthenes(limit):
    A = [i for i in range(2,limit+1)]
    P = []
    time = 0
    while True:
        prime = min(A)
        
        if prime > limit**0.5:
            break
        P.append(prime)
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
    for a in A:
        P.append(a)
    return P
L = eratosthenes(100005)
y = bisect.bisect_left(L,x)
print(L[y])

Submission status: Accepted

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

def eratosthenes(x):
  X = int(math.sqrt(x))
  prime = [i for i in range(2,x+1)]
  for _ in range(2,X+1):
    prime = [i for i in prime if i%_!=0 or i==_]
  return prime
prime = eratosthenes(2*10**5)

for i in prime:
  if x<=i:
    print(i)
    exit()

Submission status: Accepted

Solution code:
x=int(input())

def is_prime(c):
  for i in range(2,int(c**(1/2))+2):
    if c%i==0 and c!=2:
      return False
  return True

for i in range(x,100004):
  if is_prime(i)==False:
    pass
  else:
    print(i)
    break

Submission status: Accepted

Solution code:
x=int(input())
if x==2:
    print(2)
    exit()
for i in range(x,100004):
    for j in range(2,int(i**(1/2))+2):
        if i%j==0:
            break
        if j==int(i**(1/2))+1:
            print(i)
            exit()

Submission status: Accepted

Solution code:
import math

X = int(input())

while True:
  cnt = int(math.sqrt(X))
  for i in range(2, cnt+1):
    if X%i == 0:
      X += 1
      break
  else:
    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

A  = int(input())

j = A
ans = False

while ans == False:
  if is_prime(j) == True:
    print(j)
    ans = True
  else:
    j += 1

Submission status: Accepted

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

# lists = []
# for i in range(2, 100001):
#     count = 0
#     for j in range(2, i+1):
#         if i % j == 0:
#             count += 1
#     if count == 1:
#         lists.append(i)
# print(lists)
#
# max_lists = []
# for i in lists:
#     if i >= X:
#         max_lists.append(i)
#
# print(max_lists)
# print(min(max_lists))


# ----エラトステネスの篩--------

def get_prime_number(number):
    prime_list = []

    search_list = list(range(2, number + 1))

    while True:
        if search_list[0] > math.sqrt(number):
            prime_list.extend(search_list)
            break

        else:
            head_num = search_list[0]
            prime_list.append(head_num)

            search_list.pop(0)
            search_list = [num for num in search_list if num % head_num != 0]

    return prime_list


lists = get_prime_number(110000)
max_list = []
for i in lists:
    if i >= X:
        max_list.append(i)

print(min(max_list))

Submission status: Accepted

Solution code:
X=int(input())

for i in range(X,X*2):
    ok=0
    for j in range(2,i):
        if i%j == 0:
            ok += 1
    if ok == 0:
        print(i)
        break

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()
i = 0
C = True
  
while C:
  for j in range(1,X+i):
    if gcd(j, X+i) != 1:
      i += 1
      break
  else:
    C = False
    
print(X+i)

Submission status: Accepted

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

x = int(input())
while prime(x) == False:
    x += 1
print(x)

Submission status: Accepted

Solution code:
x = int(input())

is_prime = [True] * (10**6+1)   #全部Trueに
is_prime[0] = False
is_prime[1] = False

for i in range(2,int(10**3)+1):  
    if is_prime[i]:
        for j in range(i * 2, 10**6 + 1, i):
            is_prime[j] = False

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

Submission status: Accepted

Solution code:
import math

def sieve(n):
    ass = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, int(math.sqrt(n))+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    for i in range(n+1):
        if is_prime[i]:
            ass.append(i)
    return(ass)

x = int(input())
ass = sieve(10**5+4)
s = set(ass)
import bisect
if x in s:
    print(x)
else:
    i = bisect.bisect_right(ass, x)
    print(ass[i])

Submission status: Accepted

Solution code:
import math


def using_sqrt(k):
    while True:
        factor = 0  # 割り切れた回数

        # 2以外の偶数は素数ではないので無視する
        if k % 2 == 0 and k != 2:
            k += 1
            continue

        # 繰り返しの上限を対象の平方根にする
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
                factor += 1

        if factor == 0:
            return k

        k += 1


print(using_sqrt(int(input())))

Submission status: Accepted

Solution code:
import math

X = int(input())


def is_prime_number(number):
    is_dividable = lambda divided, divider: divided % divider == 0
    result = all([not is_dividable(number, divider) for divider in range(2, int(math.sqrt(number)))])

    return result


answer = X
while True:
    if is_prime_number(answer): break
    answer += 1

print(answer)

Submission status: Accepted

Solution code:
X = int(input())


def is_prime_number(number):
    is_dividable = lambda divided, divider: divided % divider == 0
    result = all([not is_dividable(number, divider) for divider in range(2, number)])

    return result


answer = X
while True:
    if is_prime_number(answer): break
    answer += 1

print(answer)

Submission status: Accepted

Solution code:
X = int(input())


def is_prime_number(number):
    result = True
    for divider in range(2, number):
        is_dividable = number % divider == 0
        if is_dividable:
            result = False
            break

    return result


answer = X
while True:
    if is_prime_number(answer): break
    answer += 1

print(answer)

Submission status: Accepted

Solution code:
import math
from functools import reduce
import itertools
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))



#nの素数判定
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=input1()
n=10**10

for p in range(X, n):
    if is_prime(p):
    	print(p)
    	break
    else:
    	continue

Submission status: Accepted

Solution code:
x = int(input())

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

while (1):
  if prime(x)==False: x += 1
  else: break
print(x)

Submission status: Accepted

Solution code:
X=int(input())
def divisors(n):
	a=[]
	for i in range(1,int(n**(1/2))+1):
		if n%i==0:
			if n==i**2:
				a.append(i)
			else:
				a.append(i)
				a.append(n//i)
	return a
ans=0
while X>0:
	if len(divisors(X))==2:
		ans=X
		break
	X+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
x = int(input())
if x == 2:
    print(2)
    sys.exit(0)
prime = []
prime_dec = True
#x_sqrt = x ** 0.5
prime.append(2)
# 素数リストの作成
for n in range(3, 1000, 2):
    prime_dec = True
    for primes in prime:
        if primes > n ** 0.5:
            break
        if n % primes == 0:
            prime_dec = False
            break
        else:
            continue
    if prime_dec:
        prime.append(n)
# 素数の探査
x -= 2
if x % 2 == 0:
    x += 1
prime_disc = True
while prime_disc:
    prime_dec = True
    x += 2
    for primes in prime:
        if primes > x ** 0.5:
            break
        if x % primes == 0:
            prime_dec = False
            break
        else:
            continue
    if prime_dec:
        print(x)
        prime_disc = False

Submission status: Accepted

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


number = X
while True:
    if is_prime(number) == True:
        print(number)
        sys.exit()
    else:
        number = number  + 1

Submission status: Accepted

Solution code:
import math

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

for i in range(x, 1000000):
    if prime_check(i):
        print(i)
        break

Submission status: Accepted

Solution code:
import math

def is_prime(n):
    return 1 if n==2 or all([n%i != 0 for i in range(2, math.ceil(math.sqrt(n))+1)]) else 0

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

Submission status: Accepted

Solution code:
def Sieve_of_Eratosthenes(N):
    if N<2:
        prime = [False for i in range(N+1)]
        return prime
 
    prime = [True for i in range(N+1)]
    prime[0] = False
    prime[1] = False
 
    for i in range(2, int(N**0.5)+1):
        if prime[i]:
            for j in range(i*2, N+1, i):
                prime[j] = False
 
    return prime

prime=Sieve_of_Eratosthenes(10**5+5)
x=int(input())
while prime[x]==False:
    x+=1
print(x)

Submission status: Accepted

Solution code:
import math

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
prime_list = callIsPrime(100004)


X = int(input())

for v in prime_list:
    if X<=v:
        print(v)
        break

Submission status: Accepted

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

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

def solve(X: int):
    while(True):
        if isPrime(X):
            print(X)
            return
        else:
            X+=1

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())

i = X

while 1:
    if i == 2:
        print(2)
        exit()
    if i % 2 == 0:
        pass
    else:
        for j in range(2, i):
            if i % j == 0:
                break

            if j == i-1:
                print(i)
                exit()
    i += 1