Created
April 8, 2021 19:28
-
-
Save ryanorsinger/74ee2f226f73fdd125a567be95b7765e to your computer and use it in GitHub Desktop.
Prime checking function(s). This is the least efficient way to check for primes, I'm sure!
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(num): | |
""" | |
Returns a boolean if the input argument is a prime number or not. | |
""" | |
if type(num) != int: | |
return False | |
if num <= 0: | |
return False | |
if num == 1: | |
return True | |
if num >= 2: | |
for i in range(2, num): | |
if num % i == 0: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment