added tut04
This commit is contained in:
18
Tutorium/tut04/src/primes.py
Normal file
18
Tutorium/tut04/src/primes.py
Normal file
@ -0,0 +1,18 @@
|
||||
def is_prime(n: int) -> bool:
|
||||
if n < 2:
|
||||
return False
|
||||
for i in range(2, n // 2 + 1):
|
||||
if n % i == 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def next_prime(n: int) -> int:
|
||||
num = n + 1
|
||||
while not is_prime(num):
|
||||
num += 1
|
||||
return num
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(next_prime(1024))
|
Reference in New Issue
Block a user