Skip to content

Instantly share code, notes, and snippets.

@iamshadmirza
Created February 21, 2018 08:33
Show Gist options
  • Save iamshadmirza/345c1184ef80bb9e1258296e7f2dbeeb to your computer and use it in GitHub Desktop.
Save iamshadmirza/345c1184ef80bb9e1258296e7f2dbeeb to your computer and use it in GitHub Desktop.
prime, non prime and composite
userinput = int(input("Enter the number to check prime\n"))
a = []
if userinput == 1:
print("One is not a prime nor a composite")
else:
if userinput == 2 or userinput%2 != 0:
for x in range(1,userinput):
if userinput%x==0 :
a.append(x)
if len(a)==1:
print("Number is prime")
else:
print("Number is composite")
else:
print("Number is not prime")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment