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:
x = int(input())

while True:
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            x = x + 1
            break
    else:
        print(x)
        exit()

Submission status: Accepted

Solution code:
import math

x = int(input())

max_num = int(math.sqrt(x * 2))
numlist = [True for i in range(x * 2 + 1)]

for i in range(2, max_num):
    if not numlist[i]:
        continue
    for j in range(i * 2, x * 2 + 1, i):
        numlist[j] = False

numlist[0:x] = [False for i in range(x)]

print(numlist.index(True))

Submission status: Accepted

Solution code:
x=int(input())
result=0
cnt=0

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

print(result)

Submission status: Accepted

Solution code:
X=int(input())
for x in range(X,2*X):
    flag=True
    for i in range(2,int(x**.5)+1):
        if x%i==0:
            flag=False
            break
    if flag:
        print(x)
        exit()

Submission status: Accepted

Solution code:
import math,sys

def hantei(x):
  for i in range(2, math.ceil(math.sqrt(x))):
    if x % i == 0:
      return False
    
  return True

x = int(input())

while True:
  if hantei(x):
    print(x)
    sys.exit(0)
    
  x += 1

Submission status: Accepted

Solution code:
X=int(input())

f=False
a=X
if X==2 or X==3:
    print(X)
    exit()
while f==False:
    for i in range(2,int(a**0.5)+1):
        if a%i==0:
            break
        if i==int(a**0.5):
            f=True
    a+=1
print(a-1)

Submission status: Accepted

Solution code:
X=int(input())

f=False
a=X
if X==2:
    print("2")
    exit()
while f==False:
    for i in range(2,a+1):
        if a%i==0:
            break
        if i==a-1:
            f=True
    a+=1
print(a-1)

Submission status: Accepted

Solution code:
x = int(input())

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

    return True

while isPrime(x) == False:
    x += 1
    
print(x)

Submission status: Accepted

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

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


def solve(X: int):
    i = X
    while True:
        # print(i, is_prime(i))
        if is_prime(i):
            print(i)
            break
        else:
            i += 1

# 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: Accepted

Solution code:
a = int(input())

is_prime = False
a_tmp = a
while is_prime == False:
  cnt = 0
  for i in range(1, a_tmp+1):
    is_div = (a_tmp % i == 0)
    if is_div:
      cnt += 1
  if cnt == 2:
    is_prime = True
    print(a_tmp)
  else:
    a_tmp += 1

Submission status: Accepted

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

# if x==2 or x==3:
#     print(x)
#     exit()
#
# lst = [i for i in range(x,x*2+2)]
#
# max = int(x**0.5)
# for i in range(2,max+1):
#     for j in lst:
#         if j%i==0:
#             lst.remove(j)
#
# print(lst[0])


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

for i in range(x,x*2+2):
    if is_prime(i):
        print(i)
        exit()

Submission status: Accepted

Solution code:
def is_prime(n):
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
n=int(input())
while not is_prime(n):
  n+=1
print(n)

Submission status: Accepted

Solution code:
x = int(input())
while 1:
    if all(x%i!=0 for i in range(2, int(x**(1/2))+1)):
        print(x)
        break
    else:
        x += 1

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

n = int(input())
ans = 0
while True:
    if is_prime(n):
       ans = n
       break
    else:
        n += 1

print(ans)

Submission status: Accepted

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

serach_number = 100004

def sieve_of_eratosthenes(target, x):
    dest = int(math.sqrt(target))
    target_list = list(range(2, target + 1))
    prime_list = []

    while True:
        num_min = min(target_list)
        if num_min >= dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)


        i = 0

        while True:
            if i >= len(target_list):
                break
            elif target_list[i] % num_min == 0:
                target_list.pop(i)
            i += 1
    while True:
        if (x in prime_list) == True:
            print(x)
            break
        else:
            x +=1


sieve_of_eratosthenes(serach_number, x)

Submission status: Accepted

Solution code:
import math

x = int(input())

def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(math.sqrt(x))):
        if x%i == 0:
            return False
    return True

while is_prime(x) == False:
    x += 1

print(x)

Submission status: Accepted

Solution code:
x = int(input())

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

while is_prime(x) == False:
    x += 1

print(x)

Submission status: Accepted

Solution code:
def Is_prime(n):
    # nが1以下ならFalse
    if n<=1:
        return False
    # nが2または3ならTrue
    if n==2 or n==3:
        return True
    # nが2の倍数ならFalse
    if n%2==0:
        return False
    # nの平方根を整数で取得
    sqrt_root = int(n**.5)
    # nがnの平方根以下の3以上の奇数で1回でも割れたらFalse
    for i in range(3,sqrt_root+1,2):
        if n%i==0:
            return False
    # 上の条件を全てぬけたものはTrue
    return True

N = int(input())
while True:
    if Is_prime(N):
        print(N)
        exit()
    N += 1

Submission status: Accepted

Solution code:
def is_prime(x: int) -> bool:
    """自然数nが素数であるかを判定する
    計算量: O(sqrt(N))
    """
    if x == 2:
        return True
    if x == 1 or x % 2 == 0:
        return False
    for k in range(3, int(x ** 0.5) + 1, 2):
        if x % k == 0:
            return False
    return True


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

Submission status: Accepted

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

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

Submission status: Accepted

Solution code:
X= int(input())

while True:
    pf={}
    m=X
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    #print(pf)

    if (len(pf)==1) and (list(pf.values())[0]==1):
        break
    else:
        X +=1
        
print(m)

Submission status: Accepted

Solution code:
X = int(input())

prime = [0] * (2 * X)

for i in range(2, 2 * X):
	if prime[i] == 0:
		for j in range(2, (2 * X) // i):
			prime[j * i] = 1
	else:
		continue

for i in range(X, 2 * X):
	if prime[i] == 0:
		print(i)
		break

Submission status: Accepted

Solution code:
#150c
import math

def isPrime(n):
	tmp=math.ceil(math.sqrt(n))
	if n==1:
		return False
	for i in range(2,tmp):
		if n%i==0:
			return False
	return True


x=int(input())
for i in range(x,100004):
	if isPrime(i):
		print(i)
		exit()

Submission status: Accepted

Solution code:
X=int(input())
n = 200000
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
for i in range(len(primes)-1):
    if X==2:
        print("2")
        break
    elif (primes[i]<X)and(X<=primes[i+1]):
        print(primes[i+1])
        break

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

X = int(input())

while not is_prime(X):
    X += 1

print(X)

Submission status: Accepted

Solution code:
X = int(input())
while True:
    pf={}
    m=X
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    if (len(pf)==1)and(list(pf.values())[0]==1):
        break
    X += 1
print(X)

Submission status: Accepted

Solution code:
import math
x=int(input())
if x<4:
    print(x)
elif x<=5:
    print(5)
else:
    ans=0
    while ans==0:
        if x%2==0:
            x+=1
        if x%10==5:
            x+=2
        i_max=math.ceil(x**0.5)+1
        for i in range(2,i_max):
            if x%i==0:
                break
            elif i==i_max-1:
                ans=x
                break
        x+=2
    print(ans)

Submission status: Accepted

Solution code:
import sys
def isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, n):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
  # nまでの数で割り切れなかったら素数
  return True

X=int(input())

while True:
    if(isPrime(X)):
        print(X)
        sys.exit()

    X+=1

Submission status: Accepted

Solution code:
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


x = ni()


def is_prime(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False
    for i in range(3, int(x**0.5) + 1, 2):
        if x % i == 0:
            return False
    return True


for ans in range(x, 10**5 + 4):
    if is_prime(ans):
        print(ans)
        break

Submission status: Accepted

Solution code:
def sieve_of_eratosthenes(n):
    prime = list(range(n + 1))
    prime[0] = prime[1] = 0
    for i in range(2, n + 1):
        if i**2 > n:
            break
        if prime[i] > 0:
            for j in range(i**2, n + 1, i):
                prime[j] = 0
    return prime
    

x = int(input())
prime = sieve_of_eratosthenes(3 * 10**5)
for i in range(x, 3 * 10**5):
    if prime[i]:
        print(i)
        exit()

Submission status: Accepted

Solution code:
from math import sqrt
x=int(input())
def chk(n):
  for i in range(2,int(sqrt(n))):
    if n%i==0:
      return False
  return True
for i in range(x,x+500):
  if chk(i):
    print(i)
    break

Submission status: Accepted

Solution code:
X = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


while 1:
    if len(make_divisors(X)) == 2:
        break
    X += 1

print(X)

Submission status: Accepted

Solution code:
x = int(input())
def is_prime(n):
    for i in range(2,int(n**0.5)+1):
        if n%i != 0:
            continue
        else:
            return False
    return True
while  True:
    if is_prime(x) == True:
        break
    else:
        x +=1
print(x)

Submission status: Accepted

Solution code:
X=int(input())
for i in range(X,2*X+1):
    a=1
    for j in range(2,X//2+1):
        if i%j==0:
            a=0
            break
    if a==1:
        ans=i
        break
print(ans)

Submission status: Accepted

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

def main():
    x = int(input())
    primes = sieve(300000)
    for p in primes:
        if x <= p:
            print(p)
            return
    raise ValueError

# O(nloglogn) https://mathtrain.jp/eratosthenes
def sieve(n):  # exclusive
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]:
            for i in range(2 * x, n, x):
                s[i] = False
    return [i for i in range(2, n) if s[i]]

if __name__ == "__main__":
    main()

Submission status: Accepted

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

def main():
    x = int(input())
    primes = furui(300000)
    for p in primes:
        if x <= p:
            print(p)
            return
    raise ValueError

# https://mathtrain.jp/eratosthenes
def furui(nmax):
    assert nmax > 2
    p = 2
    primes = list(range(2, nmax + 1))
    while True:
        if p ** 2 > nmax:
            break
        primes_next = []
        for x in primes:
            if x <= p or x % p != 0:
                primes_next.append(x)
        primes = primes_next
        p = primes[primes.index(p) + 1]
    return primes

if __name__ == "__main__":
    main()

Submission status: Accepted

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

def main():
    x = int(input())
    primes = furui(300000)
    for p in primes:
        if x <= p:
            print(p)
            return
    raise ValueError

def furui(nmax):
    assert nmax > 2
    p = 2
    primes = list(range(2, nmax + 1))
    while True:
        if p ** 2 > nmax:
            break
        primes_next = []
        for x in primes:
            if x <= p or x % p != 0:
                primes_next.append(x)
        primes = primes_next
        p = primes[primes.index(p) + 1]
    return primes

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main() :
    X = int(input())
    testing_number = X
    while(True) :
        is_prime = True
        while(True) :
            for i in range(2,testing_number) :
                if (testing_number % i == 0) :
                    is_prime = False
                    testing_number += 1
                    break
            break

        if(is_prime) :
            break

    print(testing_number)

main()

Submission status: Accepted

Solution code:
x=int(input())

def hans(n):
    a=0
    for i in range(2,n):
        if n%i==0:
            a=a+1
    
    if a==0:
        return 1
    else:
        return 0

def maxs(n):
    for i in range(n,):
        if hans(n)==1:
            return n
        else:
            n=n+1
            continue

print(maxs(x))

Submission status: Accepted

Solution code:
from math import sqrt

x = int(input())

MAX_VAL = 10**(5+1)
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(sqrt(MAX_VAL))+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

cnt = x
while True:
    if prime[cnt]:
        print(cnt)
        break
    cnt += 1

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines  

def is_prime(n):
  if n == 1:
    return False
  
  for k in range(2, int(n**0.5)+1):
    if n % k == 0:
      return False
  return True

X = int(input())

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

Submission status: Accepted

Solution code:
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string


def intinput():
    return int(input())

def listintinput():
    return list(map(int, input().split()))

def splitintinput():
    return map(int, input().split())

def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)

def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True

x = intinput()

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

Submission status: Accepted

Solution code:
n = int(input())
import math
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while True:
      if search_list[0] > math.sqrt(number):
        prime_list.extend(search_list)
        break
      else:
        head_num = search_list[0]
        prime_list.append(head_num)
        search_list.pop(0)
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list
p_l = get_primenumber(10**5+1000)


for prime in p_l:
    if prime >= n:
        print(prime)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

sosuu = [None] * 200005

for i in range(2, len(sosuu)):
    if sosuu[i] is None:
        # log(i, "is prime.")
        sosuu[i] = True
        for j in range(i*2, len(sosuu), i):
            sosuu[j] = False

x = int(input())

while sosuu[x] != True:
    # log(x)
    x += 1

print(x)

Submission status: Accepted

Solution code:
x=int(input())
l=[2]
for i in range(3,round((2*x)**0.5)):
  for j in range(len(l)):
    if i%l[j]==0:
      break
    if j==len(l)-1:
      l.append(i)
def pri(x,l):
  for i in range(len(l)):
    if x%l[i]==0 and x>l[i]:
      return 0
    if i==len(l)-1:
      return 1

while pri(x,l)==0:
  x+=1
print(x)

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    x = int(readline())
    for i in range(x, 10 ** 10 + 1):
        is_prime = True
        for j in range(2, int(i ** 0.5 + 1)):
            if i % j == 0:
                is_prime = False
                break
        if is_prime:
            print(i)
            exit()


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

a = 10 ** 6
b = int(math.sqrt(a)+1)
p = [True]*(a+1)
p[0] = False
p[1] = False

for i in range(4, a+1, 2):
  p[i] = False
  
for i in range(3, b+1, 2):
  if p[i]:
    for j in range(i+i, a+1, i):
      p[j] = False

for i in range(x, a+1):
  if p[i]:
    print(i)
    break

Submission status: Accepted

Solution code:
x = int(input())
while True:
    isAns = True
    for d in range(2, int(x ** 0.5) + 2):
        if d == x:
            continue
        if x % d == 0:
            isAns = False
            break
    if isAns:
        print(x)
        break
    x += 1

Submission status: Accepted

Solution code:
def is_prime(x):
  if x <= 1: return false
  i=2
  while i*i <= x:
    if not x%i: return False
    i+=1
  return True
 
X=int(input())
while not is_prime(X):
  X+=1
print(X)

Submission status: Accepted

Solution code:
x=int(input())

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

Submission status: Accepted

Solution code:
X = int(input())

def is_prime(n):
  if n ==2:
    return 2
  for i in range(2,n):
    if n % i ==0:
      return False
    elif i**2 > n:
      return True

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

Submission status: Accepted

Solution code:
import math

def main(x):
    if x == 2:
        return 2
    res = x
    while(1):
        if isSosuu(res):
            return res
        res += 1

def isSosuu(val):
    div = math.ceil(math.sqrt(val))
    for i in range(2,div+1):
        if val%i == 0:
            return False
    return True

x = int(input())
print(main(x))

Submission status: Accepted

Solution code:
import math
def main(X):
    if X <= 3:
        return X
    SosuuFlg = False
    while SosuuFlg == False:
        max_search = int(math.sqrt(X)+1) if math.sqrt(X) % 1 == 0 else math.ceil(math.sqrt(X))
        for i in range(2, max_search):
            if X % i == 0:
                break
        else:
            SosuuFlg = True
            return X
        X += 1
        
X = int(input())
print(main(X))

Submission status: Accepted

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

def is_prime(x):
    ma = math.ceil(math.sqrt(x))
    for i in range(2,ma+1):
        if x%i==0:
            return False
    else:
        return True

while(1):
    if x==1:
        x+=1
        continue
    elif x==2:
        print(x)
        break
    if is_prime(x):
        print(x)
        break
    x+=1

Submission status: Accepted

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

def is_prime(x):
    ma = math.ceil(math.sqrt(x))
    for i in range(2,ma):
        if x%i==0:
            return False
    else:
        return True

while(1):
    if x==1:
        x+=1
        continue
    if is_prime(x):
        print(x)
        break
    x+=1

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())

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

Submission status: Accepted

Solution code:
import math

num = int(input())
step = []
sqrt_num = int(math.sqrt(num))
count=0

while True:
  for i in range(2,sqrt_num+2):
    if num == 2:
      count=1
      break
      
    if num%i == 0:
      count = 0
      break
      
    count=1
    
  if count == 1:
    break
    
  num = num+1
  sqrt_num = int(math.sqrt(num))

print(num)

Submission status: Accepted

Solution code:
import math

X = int(input())

flag = 1
while True:
  i = 2
  flag = 1
  while i * i <=  X:
    if X % i == 0:
      flag = 0
      break
    i += 1
  
  if flag == 1:
    print(X)
    break
    
  X += 1

Submission status: Accepted

Solution code:
x = int(input())

ans = 0

for _ in range(10**5):
    if x == 2:
        print(x)
        break
    for i in range(2, int(x**0.5) + 1):
        if (x % i) == 0:
            break
        elif i == int(x**0.5): # ループの最後
            ans = x
        else:
            pass

    if ans != 0:
        print(ans)
        break
    else:
        x += 1

Submission status: Accepted

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

def is_prime(x):
    n = math.floor(math.sqrt(x))
    ans = True
    for i in range(2,n):
        if x % i == 0:
            ans = False
            break
    return ans

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

Submission status: Accepted

Solution code:
import math
def prime(n):
    for i in range(3, int(math.sqrt(n)), 2):
        if n % i == 0:
            return False
    return True
x = int(input())
if x <= 2:
    print(2)
else:
    if x % 2 != 0:
        y = x
    else:
        y = x + 1
    f = prime(y)
    while f == False:
        y += 2
        f = prime(y)
    print(y)