Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions 06/tasks/task_08_is_prime.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# task_08_is_prime.py
def is_prime(n):
# prvocisla pouze od 2!
if n < 2:
return False
# 2 je prvocislo!
if n == 2:
return True
# zbaveni se sudych cisel
if n % 2 == 0:
return False
# overeni lichych
for i in range(3, int(n) + 1, 2):
if n % i == 0:
return True
return True

def is_prime(n: int) -> bool:
"""
Vrátí True, pokud je číslo prvočíslo.
"""

print(is_prime(7))