Skip to content

Instantly share code, notes, and snippets.

@ryanorsinger
Created April 8, 2021 19:28
Show Gist options
  • Save ryanorsinger/74ee2f226f73fdd125a567be95b7765e to your computer and use it in GitHub Desktop.
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!
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