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: Runtime Error

Solution code:
X = int(input())
t = X//2 + X
a=set(range(2,t))
l=map(lambda c:range(2*c,t,c),a)
result=a.difference(*l)
result=list(sorted(result))
matchingVals = filter(lambda x : x>X, result)
res = list(matchingVals)
print(res[0])

Submission status: Runtime Error

Solution code:
def main():
    n = input('Find the next prime number greater great than: ')
    print find_next_prime(n+1)

def find_next_prime(n):
    return find_prime_in_range(n, 2*n)

def find_prime_in_range(a, b):
    for p in range(a, b):
        for i in range(2, p):
            if p % i == 0:
                break
        else:
            return p
    return None

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())

if n != 2:
    if n % 2 == 0:
        n += 1
    while not is_prime(n):
        n += 2
    print(n)
else:
    print(n)

def is_prime(q):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sympy import nextprime
n = int(input())
s = nextprime(n)
print(s)

Submission status: Runtime Error

Solution code:
#--import&define---------------------
import math
import sys
input = sys.stdin.readline
def yes():
    print("Yes")
def no():
    print("No")

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return is_prime
#--以下解答---------------------------------
x = int(input())
prime_list = primes(10**5)

i = x+1
flag = True
while flag == True:
    if prime_list[i] == True:
        print(i)
        sys.exit()
    i += 1
#

Submission status: Runtime Error

Solution code:
import math
x = input()
x = int(x)
if x in [2,3,5,7]:
    print(x)
elif x == 4:
    print(5)
elif x==6:
    print(7)
elif x==8:
    print(11)
else:
    while:
        flag = 0
        if x%2==0:
            x= x+1
            continue
        y = 3
        while y<math.sqrt(x):
            if x%y==0:
                break
            y=y + 2
            if y>math.sqrt(x):
                flag=1
                break
        if flag == 1:
            print(x)
            break
        x = x+2

Submission status: Runtime Error

Solution code:
def get_primenumber(N):
    prime_list = [2]
    for num in range(3,N+1,2):
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

n = int(input())
l = get_primenumber(n+10)
lm = get_primenumber(n)
print(l[int(len(lm))])

Submission status: Runtime Error

Solution code:
import math

n = int(input())

if n == 2 or n == 1:
    print(2)
else:
    if n % 2 == 0:
        n += 1

i = 3

m = 2 * math.floor(n/2) + 1

while i < m:
    Prime = True
    if n % i == 0:
        Prime = False
        i = 3
        n += 2
    i += 2

if Prime == True:
    print(n)

Submission status: Runtime Error

Solution code:
import sympy
i = int(input())
p = sympy.nextprime(i, 1)
print(p)

Submission status: Runtime Error

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

def isPrime(n):
    if n % 2 == 0:
        return False
  
    m = math.floor(math.sqrt(n))
    for p in prime_numbers:
        if n % p == 0:
            return False
        if p > m:
        # 素数がnの平方根を超えたら終了
            break
    return True

for i in range(X, 10**9):
    if (is_prime(i)):
        print(i)
        break

Submission status: Runtime Error

Solution code:
if (N <= 1):
  print(2) 
int prime = N; 
bool found = false; 
while (!found):
  prime++ 
  if (isPrime(prime)):
    found = true; 
print(prime)

Submission status: Runtime Error

Solution code:
#C
from sympy import sieve
x = int(input())
print(min([i for i in sieve.primerange(x,10**6)]))

Submission status: Runtime Error

Solution code:
n = int(input())

if n != 2:
    if n % 2 == 0:
        n += 1
    for p in range(n, 10**5, 2):
        if is_prime(p):
            print(p)
            break
else:
    print(n)

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

Submission status: Runtime Error

Solution code:
from sympy import nextprime
x = int(input())
y = float(x - 0.1)
print(nextprime(y))

Submission status: Runtime Error

Solution code:
pip install sympy
from sympy import nextprime 
n = int(input())
print(nextprime(n))

Submission status: Runtime Error

Solution code:
X = int(input())
def sosu(n):
  for i in range(0,n//2):
    if X % i == 0:
      return False
    return True
if sosu(X) == True :
  print(X)
else:
  while sosu(X) == False:
    X += 1
  print(X)

Submission status: Runtime Error

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_b == 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: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sympy import nextprime,isprime
X=int(input())
print(X if isprime(X) else nextprime(X))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sympy import nextprime
a = int(input())
print(nextprime(a))