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

n = int(input())

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

ans = n

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

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

print(ans)

Submission status: Accepted

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


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

    return True


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


print(calc(X))

Submission status: Accepted

Solution code:
import math

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


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

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


print(solve(X))

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())
chk = True
result = 0

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

Submission status: Accepted

Solution code:
N = int(input())


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


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

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):
        print(i)
        exit()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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

Submission status: Accepted

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

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

X = int(input())

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

print(X)

Submission status: Accepted

Solution code:
import numpy as np

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

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

X = int(input())

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

print(X)

Submission status: Accepted

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

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

X = int(input())

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

print(X)

Submission status: Accepted

Solution code:
import numpy as np

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

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

X = int(input())

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

print(X)

Submission status: Accepted

Solution code:
import numpy as np

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

X = int(input())

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

print(X)

Submission status: Accepted

Solution code:
X = int(input())
for x in range(X,1000000):    
    for i in range(2,x):
        if x%i ==0:
            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

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

Submission status: Accepted

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

x = int(input())

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

print(x)

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 permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

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

X = INT()

def is_prime(num):
   """ 素数判定 """
   from math import sqrt
   if num < 2:
       return False
   if num in [2, 3, 5]:
       return True
   if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
       return False
   # 疑似素数(2でも3でも割り切れない数字)で次々に割っていく
   prime = 7
   step = 4
   num_sqrt = sqrt(num)
   while prime <= num_sqrt:
       if num % prime == 0:
           return False
       prime += step
       step = 6 - step
   return True

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(next_prime(n))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

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

        if isDivisible:
            break
        else:
            divider += 1

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

print(X)

Submission status: Accepted

Solution code:

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

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
import bisect

#エラトステネスの篩
def sieve(n):
    import math
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        #ここで篩落としてる,wikiの2番目
        data = [e for e in data if e % p != 0]



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

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

Submission status: Accepted

Solution code:
import math

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

    return True

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

    max = 10 ** 5

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

    print(ans)

if __name__ == '__main__':
    main()

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

print(X)

Submission status: Accepted

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

Submission status: Accepted

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

for x in itertools.count(X):
    # 2~x/2で割ってみて，すべての余りが0でなければ
    isprime = all([x % y != 0 for y in range(2,int(x/2)+1)])
    if isprime:
        prime = x
        break

print(prime)

Submission status: Accepted

Solution code:
# ABC149 C
import numpy as np
X = int(input())
numList = np.arange(X*2)

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

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

X = int(input())

nextprime = 0
i = -1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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



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

resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x = int(input())


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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

while(flag):
  if x==2:
    break
  for j in reversed(range(2, x)):
    if x % j == 0:
      #print('{} is not prime.'.format(x))
      flag = True
      break
    else:
      prim = x
      flag = False
  x += 1
print(prim)

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

def main():
    X = int(input())
    while True:
        if is_prime(X):
            print(X)
            exit()
        X+= 1

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
#import copy
#import fractions
#
###############入  力###################
#a, b, c, d = map(int, input().split())  # a=2 b=4 c=5 d =7
#a = list(map(int, input().split()))     # a = [2, 4, 5, 6]
#s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
##行数指定
##3
##hoge
##foo
##bar
#n=int(input())
#string_list=[input() for i in range(n)] #['hoge','foo','bar']
#
###############初期化、コピー##############
#a=[0]*5 #[0, 0, 0, 0, 0]
#b=copy.deepcopy(a)  #2次元配列はこうコピーする
#b2=a[:]  #1次元のときはコピーはこれで良い
#
###############小数点表示################
#a = 0.364364
#print(a) #0.364364
#print("{:.6f}".format(a)) #0.364364
#print("{:.4f}".format(a)) #0.3644 小数点第4位に丸めることもできる。
#
###############ゼロ埋め・幅寄せ################
#print("python".ljust(15,'-')) # 左詰め　　　 #python---------
#print("python".center(15,'-'))# 中央寄せ　　#-----python----
#print("python".rjust(15,'-')) # 右詰め　　　 #---------python
#print(str(29).rjust(10,'0')) #10桁ゼロ埋め　 #0000000029
#
###############文字列操作################
#'abc123def'[:] #すべての文字列が取れる #'abc123def'
#'abc123def'[-1:] #終端文字がとれる    #'f'
#'abc123def'[:-1] #最後の1文字以外のものがとれる。 #'abc123de'
#'abc123def'[::-1] #文字が逆転する #'fed321cba'
#
###############二分探索################
#import bisect
#listA=[1,2,5,2,4,6,7,8,6,56,3,56,76,34,32,2,6,0,32,6,0] 
#listA.sort()
#zeroindex=bisect.bisect_right(listA,0) #ソートされたリスト内で0の場所を探し、右側Indexを返す
#clearlistA=listA[zeroindex:]#0以下が存在しないリストを得る
#
#
###############最小公倍数,最大公約数
#import fractions
#a,b=map(int, input().split())
#a,b= 24, 6
#f=fractions.gcd(a,b)
#f2=a*b//f
#print(f,f2)
#
###############四則演算
#a + b #足し算（加算）: +演算子
#a - b#引き算（減算）: -演算子
#a * b#掛け算（乗算）: *演算子
#a / b#割り算（除算）: /演算子
#a// b#割り算の整数部（整数除算）: //演算子
#a % b#割り算の剰余（余り, mod）: %演算子
#a** b#べき乗: **演算子

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

s=0
for j in XX:
    if (s==1):
        break
    for i in range(2, j+1):
        N= j % i
#        print('j=' ,j ,' i=' ,i, N)
        if (N ==  0 and i==j ):
            print(j)
            s=1
        if (N ==  0):
          #  print('true')
            break
#        else:
#            print(j)

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

# input
X = int(input())

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

# output
print(x)

Submission status: Accepted

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


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


main()

Submission status: Accepted

Solution code:
#149c
X = int(input())

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

    return True
  

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

Submission status: Accepted

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

Submission status: Accepted

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

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

def main(X):
  if is_prime(X) == True:
    print(X)
  else:
    return main(X+1)

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

Submission status: Accepted

Solution code:
# coding:utf-8

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

#X = str(raw_input()).split()
X = int(raw_input())

k = X
flag = 0


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



print(str(ans));

Submission status: Accepted

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

for i in range(int(x**0.5)+1):
    if li[i]:
        m = 2
        while(i*m<=x):
            li[i*m] = False
            m += 1
#print(li)
for i in range(x):
    if i>=n and li[i]:
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
def isprime(n): # N<=10^7のとき最速の素数判定法だが,10^18ほどになると実行時間10sくらいになるためMiller_Rabinを使うべし
    import math as ma
    if n == 2 or n == 3:
        return True
    if n % 2 == 0 or n % 3 == 0:
        return False
    for i in range(6, (int(ma.sqrt(n))+1) + 1, 6):
        if n % (i-1) == 0 or n % (i+1) == 0: # ∀p∈P, p = 6n±1
            return False
    return True
while True:
    if isprime(X):
        print(X)
        break
    X += 1

Submission status: Accepted

Solution code:
primes = [2]

X = int(input())


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


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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

n = int(input())


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


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

Submission status: Accepted

Solution code:
import numpy as np

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

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

Submission status: Accepted

Solution code:
from bisect import bisect_left

X = int(input())

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

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

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

Submission status: Accepted

Solution code:
# Primality test
import numpy as np

n = 100003 # limit

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

# solve
X = int(input())

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

Submission status: Accepted

Solution code:
# Primality test
import numpy as np

n = 100003 # limit

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

primes = primes.nonzero()[0]

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

Submission status: Accepted

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

n = int(input())

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

Submission status: Accepted

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

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

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

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


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