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 sqrt, floor

def solve(x):
    p1s = [2, 3, 5, 7]
    if x in p1s:
        return x
    maxp = 100003
    l = p1s + [i for i in range(11, maxp + 1, 2) if i % 3 != 0 and i % 5 != 0 and i % 7 != 0]
    num = x
    if num % 2 == 0:
        num += 1
    while True:
        if all(num % m != 0 for m in l if m < floor(sqrt(num))):
            return num
        num += 2

_x = int(input())
print(solve(_x))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

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

print(X)

Submission status: Accepted

Solution code:
import numpy as np
def prime():
    a = np.ones(110000)
    t = []
    for i in range(2,110000):
        if a[i] == 0:
            continue
        t.append(i)
        j=i+i
        while j < 110000:
            a[j] = 0
            j = j + i

    for i in range(int(input()),110000):
        if i in t:
            print(i)
            break

prime()

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

Submission status: Accepted

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

X = int(input())
ans = X

while not is_prime(ans):
    ans += 1

print(ans)