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:
from math import sqrt as sq
def primeChecker(n):
    for i in range(2,int(sq(n))+1):
        if n%i==0:
            return False
    return True

def main():
    n=int(input())
    if n==2: print(n)
    elif n%2==0:
        n+=1
        while 1:
            if primeChecker(n):
                print(n)
                break
            n+=2
    
main()

Submission status: Wrong Answer

Solution code:
from math import sqrt as sq
def primeChecker(n):
    for i in range(2,int(sq(n))+1):
        if n%i==0:
            return False
    return True

def main():
    n=int(input())
    if n%2==0:
        n+=1
    while 1:
        if primeChecker(n):
            print(n)
            break
        n+=2
    
main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

x = int(input())
j = True

if x % 2 == 0:
    if x == 2:
        j = False
        y = 2
    else:
        y = x + 1
else:
    y = x

while j:
    for i in range(3, y, 2):
        if y%i == 0:
            j = True
            y += 2
            continue
        else:
            j = False
print(y)

Submission status: Wrong Answer

Solution code:
n = int(input())

def isprime(x):
    if x == 2:
        return True
    elif x == 4:
        return False
    for i in range(3, int(x**0.5), 2):
        if x % i == 0:
            return False
    return True

i = n
while True:
    if isprime(i):
        break
    else:
        i += 1
print(i)

Submission status: Wrong Answer

Solution code:
X=int(input())

answer=0
base=X
a=0
b=0

while a==0:
    for i in range(base//2):
        if base%(i+2)==0:
            base+=1
            break
        else:
            if i==base//2-1:
                print(base)
                a+=1
                break

Submission status: Wrong Answer

Solution code:
n = int(input())

def isprime(x):
    if x == 2:
        return True
    for i in range(3, int(x**0.5), 2):
        if x % i == 0:
            return False
    return True

i = n
while True:
    if isprime(i):
        break
    else:
        i += 1
print(i)

Submission status: Wrong Answer

Solution code:
import math
def main():
    X = int(input())
    if X % 2 == 0:
        X = X + 1
    while True:
        if trial_division(X):
            print(X)
            break
        X += 2
def trial_division(t):
    d = int(math.sqrt(t))
    for i in range(2, d):
        if t % i == 0:
            return False
    return True
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
if n != 2:
    while pow(2, n-1, n) != 1:
        if n % 2 == 1:
            n += 2
        else:
            n += 1
print(n)

Submission status: Wrong Answer

Solution code:
s = [True for i in range(200000)]
s[0] = False
s[1] = False
n = int(input())
for i in range(2,len(s)):
  if not s[i]:
    continue
  for j in range(i+i, len(s), i):
    s[j] = False
for i in range(n+1, len(s)):
  if s[i]:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
x = int(input())

if x ==2:
    print(2)
    exit()
if x%2 == 0:
    x += 1

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

while True:
    if is_prime(x):
        print(x)
        exit()
    x+=1

Submission status: Wrong Answer

Solution code:
n = int(input())
if n != 2:
    while pow(2, n-1, n) != 1:
        n += 1
print(n)

Submission status: Wrong Answer

Solution code:
from math import sqrt


def is_prime(n):
    if n % 2 == 0:
        return False
    for i in range(3, int(sqrt(n)), 2):
        if n % i == 0:
            return False
    return True


X = int(input())
while True:
    if is_prime(X):
        print(X)
        break
    X += 1

Submission status: Wrong Answer

Solution code:
n = int(input())
if n == 2:
    n = 2
else:
    while pow(2, n-1, n) != 1:
        n += 1
print(n)

Submission status: Wrong Answer

Solution code:
def prm(x):
  if x == 1 or x == 4:
    return False
  for i in range(1,int(x**0.5+1)):
    if x%i == 0:
      return False
  return True
X=int(input())
for i in range(X,X**2):
  if prm(i):
    print(i)
    break

Submission status: Wrong Answer

Solution code:
X = int(input())

for p in range(2,X):
    if X%p==0:
        X=X+1
if X>=99992:
    print(100003)
else:
    print(X)

Submission status: Wrong Answer

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+400)
ans=[]

l = sorted(l, reverse=True)
for i in l:
  if i >= n:
    ans.append(i)
  else:
    break

print(ans)
print(ans[len(ans)-1])

Submission status: Wrong Answer

Solution code:

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+100,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

def main():
    prime = []
    ans = []
    number = int(input())
    print(max(get_primenumber(number)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

X=int(input())

if X==2:
    count=0
    print(X)
else:
    count=1

while(count==1):
    for n in range(2,X):
        if (X%n==0):
            X+=1
            break
        if (n>math.sqrt(X)):
            count=0
            break
print(X)

Submission status: Wrong Answer

Solution code:

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+20,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

def main():
    prime = []
    ans = []
    number = int(input())
    print(max(get_primenumber(number)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
import json


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

X = int(input())

while True:
    if is_prime(X):
        break
    X += 1
print(X)

Submission status: Wrong Answer

Solution code:
X = int(input())

count = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
inp = int(input())

if inp == 2:
    print(str(inp)+' is prime')
else:
    for i in range(2, inp):
        if inp%i == 0:
            print(str(inp)+' is not prime')
            break
        if i == inp-1:
            print(str(inp)+' is prime')

Submission status: Wrong Answer

Solution code:
X=int(input())
y=0
if X==2:
  print(X)
else:
  for i in range(2,X):
    if X%i==0:
      X+=1
  print(X)

Submission status: Wrong Answer

Solution code:
X = int(input())

count = 0

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

Submission status: Wrong Answer

Solution code:
x = int(input())



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



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

Submission status: Wrong Answer

Solution code:
X=int(input())
for i in range(2,X+2):
  if(X%i==0):
    X+=1
    continue
  else:
    if(i<X):
      continue
    else:
      print(X)

Submission status: Wrong Answer

Solution code:

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+2,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

def main():
    prime = []
    ans = []
    number = int(input())
    print(max(get_primenumber(number)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
x = int(input())
while True:
    if x % 2 != 0:    
        for m in range(3,x,2):
            if x % m == 0:
                break
        else:
            break
    x += 1
print (x)

Submission status: Wrong Answer

Solution code:
X=int(input())
y=0
if X==2:
  print(X)
else:
  for i in range(2,X):
    if X%i==0:
      X+=1
  print(X)

Submission status: Wrong Answer

Solution code:
import math
i=int(input())
j=int(math.sqrt(i))
k=0
m=i
while k==0:
  if i==2:
    i=3
    break
  if i==3:
    i=4
    break
  if m%2!=0:
    if m%3!=0:
      for l in range(7,j,2):
        if m%l!=0:
          break
        if l==j:
          k=1
          break
  m+=1
m=m-1
print(str(m))

Submission status: Wrong Answer

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

n = 10000
list1 = []
for i in range(2, n):
    for j in range(2, i+1):
        if i % j == 0:
            if i == j:
                list1.append(i)
            else:
                break

for x in range(len(list1)):
    if list1[x]>X:
        print(list1[x])
        break

Submission status: Wrong Answer

Solution code:
def func(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
n=int(input())
while True:
    if func(n):
        break
    n=n+1
print(n)

Submission status: Wrong Answer

Solution code:
X = int(input())

if X%2 ==0:
  A = X-1
else:
  A = X-2

ans = 0
while ans == 0:
  A += 2
  for n in range(2,int(A/2)+1):
    ans = A
    if A%n == 0:
      ans = 0
      break

ans = A
print(ans)

Submission status: Wrong Answer

Solution code:
X = int(input())

if X%2 ==0:
  A = X-1
else:
  A = X-2

ans = 0
while ans == 0:
  A += 2
  for n in range(2,int(A/2)):
    ans = A
    if A%n == 0:
      ans = 0
      break

ans = A
print(ans)

Submission status: Wrong Answer

Solution code:
X=int(input())
count = 0

for i in range(100000):
    for j in range(1,X):
        if X % j == 0:
            count = count + 1
            break
    if count == 0:
        break
    count = 0
    X = X + 1

print(X)

Submission status: Wrong Answer

Solution code:
X=int(input())
for i in range(2,X):
  if(X%i==0):
    X+=1
    continue
  else:
    if(i<X):
      continue
    else:
      print(X)

Submission status: Wrong Answer

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+400)
l = sorted(l, reverse=True)
#print(l)
ans=[]
for i in l:
  if i > n:
    ans.append(i)    
#print(ans)
print(ans[len(ans)-1])

Submission status: Wrong Answer

Solution code:
X = int(input())

for p in range(2,X):
    if X%p==0:
        X=X+1
print(X)

Submission status: Wrong Answer

Solution code:
X=int(input())
for i in range(2,X):
  if(X%i==0):
    X+=1
    break
  else:
    if(i<X):
      continue
    else: 
      print(X)

Submission status: Wrong Answer

Solution code:
x = int(input())
ps = set(range(x + 1, 4 * x + 1))
for i in range(2, x+1):
    for j in range(0, 4 * x + 1, i):
        if j in ps:
            ps.remove(j)
print(min(ps))

Submission status: Wrong Answer

Solution code:
X = int(input())
result = []
i = X
for i in range(X,X*2):
    i += 1
    if i > 1:
        for j in range (2, i):
            if (i % j) == 0:
                break
        else:
            result.append(i)
print (min(result))

Submission status: Wrong Answer

Solution code:
X=int(input())
count = 0

for i in range(100000):
    for j in range(1,X):
        if X % j == 0:
            count = count + 1
            break
    if count == 0:
        break
    counr = 0
    X = X + 1

print(X)

Submission status: Wrong Answer

Solution code:
pn=[2]
A=100000

x = int(input())
if x==2:
    print(2)
    exit()

for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:
        pn.append(L)
        if x<L:
            print(L)
            exit()
        
#print(pn)

Submission status: Wrong Answer

Solution code:
x=int(input())
if x!=2:
    for i in range(x,1000000):
        if ((2)**(i-1))%i==1:
            print(i)
            break
else:
    print(2)

Submission status: Wrong Answer

Solution code:

X=int(input())
for i in range(2,X):
  if(X%i==0):
    X+=1
    break
  else :
  	print(X)

Submission status: Wrong Answer

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

count=1


while(count==1):
    for n in range(2,X+1):
        if (X%n==0):
            X+=1
            break
        if (n>math.sqrt(X)):
            count=0
            break
print(X)

Submission status: Wrong Answer

Solution code:
X = int(input())
while X != 'prime':
    for i in range(2,X):
        if X%i == 0:
            X+=1
            continue
    break
print(X)

Submission status: Wrong Answer

Solution code:
import fractions
X = int(input())

primes = set()

# 2以上m以下の素数を数え上げる
n = 2
while n <= (10**5+3):
    # 自身より小さい全ての素数で割り切れなければ、素数とみなせる
    if all(n % i != 0 for i in primes):
        primes.add(n)
        if(n > X):
          print(n)
          exit()
    n += 1

Submission status: Wrong Answer

Solution code:
primes=[2]
x = int(input())
for i in range(3, 10**5+1):
  for p in primes:
    if i % p == 0:
      break
  else:
    primes.append(i)
    if x <= i:
      break
print(primes[-1])

Submission status: Wrong Answer

Solution code:
X = int(input())


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


def main(x):
    while True:
        if is_prime(x):
            return x
        x += 1

print(main(X))

Submission status: Wrong Answer

Solution code:
x = int(input())

def is_prime(num):
  for i in range(2, num):
    if num % i == 0:
      return False
    
  return True

count_x = x

while count_x <= 10**5:
  if is_prime(count_x) == True:
    print(count_x)
    break
  else:
    count_x += 1
    pass

Submission status: Wrong Answer

Solution code:
def sosuu(Y):
  Z = Y - 1
  for i in range(Z):
    if Y % Z == 0 and Z != 1:
      return False
    Z = Z - 1
    if Z == 1:
      return True

def answer(X):
  Y = X + 1
  while True:
    if sosuu(Y):
      break
    Y = Y + 1
  return Y

X = int(input())
print(answer(X))

Submission status: Wrong Answer

Solution code:
import math
a=int(input())
for i in range(100000):
 for k in range(2, int(math.sqrt(i+a)) + 1):
        if (i+a) % k != 0:
         print(i+a)
         break
 else:
  continue
 break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def sosu(x):
    arr = factorization(x)
    if len(arr) == 1:
        return True
    else:
        return False

def solve(X: int):
    ans = 100003
    for i in range(X, 10**5 + 1):
        #if i % 2 == 0 and X != 2:
        #    continue
        if sosu(i):
            ans = i
            break

    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

x = int(input())

def is_prime(x):
    result = True
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            result = False
            break
    return result
x += 1
while True:
    if is_prime(x):
        print(x)
        break
    x += 1

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
X = int(input())
ans = 0
pn = [2]
flag = 0
for i in range(3,100005):
  for k in pn:
    if i%k == 0:
      flag = 0
      break
    else:
      flag = 1
  if flag == 1:
    pn.append(i)
for i in range(len(pn)-1):
  if pn[i] < X < pn[i+1]:
    ans = pn[i+1]
print(ans)

Submission status: Wrong Answer

Solution code:
X=int(input())
y=0
if X==2:
  print(X)
else:
  for i in range(X-2):
    if X%(2+i)==0:
      X+=1
    else:
      print(X)
      exit()

Submission status: Wrong Answer

Solution code:
import math

x = int(input())

def is_prime(x):
    result = True
    for i in range(2, int(math.sqrt(x))):
        if x % i == 0:
            result = False
            break
    return result
x += 1
while True:
    if is_prime(x):
        print(x)
        break
    x += 1