Created
February 21, 2018 08:33
-
-
Save iamshadmirza/345c1184ef80bb9e1258296e7f2dbeeb to your computer and use it in GitHub Desktop.
prime, non prime and composite
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
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