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:
n = int(input())
for i in range(n, 10**6) :
    for j in range(2, i) :
        if i % j == 0 :
            break
    else :
        print(i)
        break

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())

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

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

Submission status: Accepted

Solution code:
import math

def judge_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:
  if judge_prime(x):
    print(x)
    exit()
  else:
    x += 1

Submission status: Accepted

Solution code:
import math as m

x = int(input())

def isPrime(x):
	if x <= 2:
		return True
	
	if x % 2 == 0:
		return False
	
	n = m.floor(m.sqrt(x))
	
	for i in range(3, n, 2):
		if x % i == 0:
			return False
	
	return True



for i in range(x, 2 * x - 1):
	if isPrime(i):
		print(i)
		break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import sqrt
X = int(input())
def is_prime_next(X):
    X_sqrt = int((sqrt(X)+1)/6) 
    if X==2 or X==3:
        return X
    if X%2 == 0:
        return None
    if X%3 == 0:
        return None
    for i in range(1, X_sqrt+1):
        if X % (6*i+1) == 0 or X % (6*i-1) == 0:
            return None
    return X
while(1):
    X_keep = is_prime_next(X)
    if X_keep != None:
        break
    X += 1
print(X)

Submission status: Accepted

Solution code:
import bisect
primes = []
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 * p, n+1, p): 
                prime[i] = False
        p += 1
    for p in range(2, n): 
        if prime[p]: 
            primes.append(p)
SieveOfEratosthenes(10**5+30)
x = int(input())
print(primes[bisect.bisect_left(primes, x)])

Submission status: Accepted

Solution code:
x = int(input())

def isPrime(x):
    if x == 1:
        return False
    for i in range( 2, int(pow(x, 1/2))+1 ):
        if x%i==0:
            return False
    return True

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

Submission status: Accepted

Solution code:
def isPrime(num):

    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False

    return True


X = int(input())
n = X

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

print(n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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