1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-09 11:09:07 +01:00
CodeWars/6kyu/is_a_number_prime/solution.py
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

16 lines
283 B
Python

import math
def is_prime(num):
if num <= 1:
return False
elif num == 2:
return True
elif num % 2 == 0:
return False
bound = int(math.ceil(math.sqrt(num)))
for div in range(3, bound + 1, 2):
if num % div == 0:
return False
return True