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: Wrong Answer

Solution code:
x = int(input())
try_n = x - 1
b_flg = True
roop_c = 0
while b_flg:
    try_n += 1
    for n in range(2, try_n):
        roop_c += 1
        if try_n == 2: # 2の場合は特別
            b_flg =False
            break
        if try_n % n == 0: # 素数でないことが確定した場合
            break
        else:
            if roop_c == try_n - 2:
                b_flg = False
print(try_n)

Submission status: Wrong Answer

Solution code:
import sys
x = int(input())
if x == 2:
    print(2)
    sys.exit()
prime = [2]
for i in range(3, 1000000, 2):
    all(i % p != 0 for p in prime) and prime.append(i)
    if i > x and i in prime:
        print(i)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
x = int(input())
if x == 2:
    print(2)
    sys.exit()
prime = [2]
for i in range(3, 1000000, 2):
    all(i % p != 0 for p in prime) and prime.append(i)
    print(prime)
    if i > x and i in prime:
        print(i)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import numpy as  np
import math
 
def get_sieve_of_eratosthenes(n):
    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)
        data = [e for e in data if e % p != 0]
 
 
x = int(input())
data = get_sieve_of_eratosthenes(x+1000)
data = np.array(data)
indices = np.where(data > x)[0]
# print(indices)
print(data[indices[0]])