Last active
May 7, 2019 20:17
-
-
Save frogandcode/f60c18c8637d241230252249ccc1268c to your computer and use it in GitHub Desktop.
Is a number prime?
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
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