Last active
January 27, 2018 04:23
-
-
Save Ventsislav-Yordanov/dc67455197497e3e6eacf336058c22be to your computer and use it in GitHub Desktop.
Function that checks if the passed number is prime or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_prime(n): | |
if n <= 1: | |
return False | |
elif n <= 3: | |
return True | |
elif n % 2 == 0 or n % 3 == 0: | |
return False | |
current_number = 5 | |
while current_number * current_number <= n: | |
if n % current_number == 0 or n % (current_number + 2) == 0: | |
return False | |
current_number = current_number + 6 | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment