def solution(n: int) -> int:
while True:
n = n + 1
for i in range(1, n):
if n % i == 0 and i != 1:
break
if i == n - 1:
return n
assert solution(0) == 2
assert solution(2) == 3
assert solution(5) == 7
assert solution(181) == 191
def solution(n: int) -> int:
while True:
n += 1
num = 0
for i in range(1, n + 1):
if n % i == 0:
num += 1
if num == 2:
break
return n
assert solution(0) == 2
assert solution(2) == 3
assert solution(5) == 7
assert solution(181) == 191
def solution(n:int) -> int:
for x in range(n+1,9999999):
if x > 2:
for i in range(2,x):
if x%i== 0:
break
else:
return x
else:
return 2
assert solution(0)==2
assert solution(2)==3
assert solution(5)==7
assert solution(181)==191
def solution(n: int) -> int:
if n == 0 or n == 1:
return 2
else:
x = n + 1
while True:
for i in range(2, x):
if x % i == 0:
break
else:
return x
x += 1
assert solution(0) == 2
assert solution(2) == 3
assert solution(5) == 7
assert solution(181) == 191
import math
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
return True
def solution(n: int) -> int:
while True:
n += 1
if is_prime(n):
return n
assert solution(0) == 2
assert solution(2) == 3
assert solution(5) == 7
assert solution(181) == 191
def solution(n: int) -> int:
while True:
s_list = []
n += 1
for i in range(1, n+1):
if n % i == 0:
s_list.append(i)
if s_list == [1, n]:
break
return n
assert solution(0) == 2
assert solution(2) == 3
assert solution(5) == 7
assert solution(181) == 191
def solution(n: int) -> int:
while True:
n = n + 1
for i in range(1, n):
if n % i == 0 and i != 1:
break
if i == n - 1:
return n
assert solution(0) == 2
assert solution(2) == 3
assert solution(5) == 7
assert solution(181) == 191
def solution(n: int) -> int:
if n < 2:
return 2
n = n + 1
while 1:
i = 2
k = 0
# while 2 <= i <= n - 1:
for i in range(2, n - 1):
if n % i == 0:
n = n + 1
k = k + 1
break
else:
i = i + 1
if k == 0:
return n
assert solution(0) == 2
assert solution(2) == 3
assert solution(5) == 7
assert solution(181) == 191
def solution(n: int) -> int:
if (n<2):
return 2
max_left, min_right = 0,0
for i in reversed(range(2, n)):
for j in range(2, i):
if (i%j==0):
break
else:
max_left = i
break
i = n + 1
while(True):
for j in range(2, i):
if (i%j ==0):
break
else:
min_right = i
break
i += 1
if(max_left !=0 and min_right!=0):
if(min_right - n > n - max_left):
return max_left
elif(min_right - n < n - max_left):
return min_right
else:
return min_right
elif(max_left ==0):
return min_right
else:
return max_left