Skip to content

Instantly share code, notes, and snippets.

@vikychoi
Created January 27, 2018 15:49
Show Gist options
  • Save vikychoi/5c23a241368fdae2f82a74ee1643bc34 to your computer and use it in GitHub Desktop.
Save vikychoi/5c23a241368fdae2f82a74ee1643bc34 to your computer and use it in GitHub Desktop.
Check Primality Function
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