Created
July 21, 2021 13:33
-
-
Save igorvanloo/dc432178ec19d12f84c08180df3a3fe9 to your computer and use it in GitHub Desktop.
Is prime Function
This file contains hidden or 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(x): | |
if x <= 1: | |
return False | |
elif x <= 3: | |
return True | |
elif x % 2 == 0: | |
return False | |
else: | |
for i in range(3, int(math.sqrt(x)) + 1, 2): | |
if x % i == 0: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment