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

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(10 ** 5):
	ans = x + i
	if is_prime(ans):
		print(ans)
		break

Submission status: Accepted

Solution code:
a, = [list(map(int, s.split())) for s in open(0)]

flag = True
c = a[0]
while flag:
    p = int(c ** 0.5) + 1
    for i in range(2, p):
        if c % i == 0:
            c += 1
            break
    else:
        flag = False
print(c)

Submission status: Accepted

Solution code:
X = int(input())
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]]
xlist = primes(X)

for i in range(X,2*X+1):
    flag = True
    for j in xlist:
        if j != X and i%j == 0:
            flag = False
    if flag:
        print(i)
        break

Submission status: Accepted

Solution code:
X=int(input())
primelist=[]
sqX=int(X**0.5)
i=2

while True:
  is_pr=True
  sqi=int(i**0.5)
  for p in primelist:
    if i%p==0:
      is_pr=False
      break
    if p>sqi:
      break
  if is_pr:
    primelist+=[i]
    if i>=X:
      break
  i+=1

print(primelist[-1])