Created
January 27, 2018 15:49
-
-
Save vikychoi/5c23a241368fdae2f82a74ee1643bc34 to your computer and use it in GitHub Desktop.
Check Primality Function
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
def checkprime(input): | |
counter = 0 | |
for i in range(1, input+1): | |
result = input // i | |
print(result, counter) | |
if (result * i == input): | |
counter += 1 | |
if (counter > 2): | |
return False | |
return True | |
number = int(input("Please entre a number! I will check whether it is a prime nuumber or not.")) | |
if (checkprime(number)): | |
print("This is a prime number") | |
else: | |
print("this is not a prime number") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment