Skip to content

Commit

Permalink
added the is_prime function
Browse files Browse the repository at this point in the history
  • Loading branch information
starrytc committed Oct 29, 2024
1 parent e98c461 commit 198ba49
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions willing-participants/Sksronin/pr_tutorial/simple_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@ def factorial(value):
return 1
else:
return value * factorial(value - 1)

def is_prime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True

0 comments on commit 198ba49

Please sign in to comment.