Skip to content

Instantly share code, notes, and snippets.

@frogandcode
Last active May 7, 2019 20:17
Show Gist options
  • Save frogandcode/f60c18c8637d241230252249ccc1268c to your computer and use it in GitHub Desktop.
Save frogandcode/f60c18c8637d241230252249ccc1268c to your computer and use it in GitHub Desktop.
Is a number prime?
print("Gimme an integer and I’ll tell you if it’s prime:")
number = int(input())
def is_prime(number):
divisor = 2 # Start with most likely factor and increment
while divisor <= (number / 2):
if ((number % divisor) == 0): return False
divisor += 1
return True
if is_prime(number):
print(f"Hell yeah, {number} is prime!")
else:
print(f"{number} is not prime :(")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment