Prime/Composite Number Program
This is just a simple prime/composite number program for how to print prime and composite numbers
primelist = ("2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97")
def primenumber(num):
'''
while True:
answer = str(input("Would you like to print a list of all prime numbers from 1 to 100 or enter a number to tell whether it is prime or composite? All/Single "))
if answer == "single" :
'''
#num = int(input("Enter the number you want: "))
#add new if statement
if num == 2:
print("it is a prime number")
else:
print("Let's find out if that number is prime or not.")
composite = 0
for i in range(2,num):
if (num % i) == 0:
composite = composite + 1
print(composite)
if composite == 0:
print(num, "is a prime number")
else:
print(num,"is a composite number")
#print(num, "is a prime number")
#print(i,"times",num//i,"is",num)
#print(num, "is a prime number")
'''
elif answer == "prime 100":
print(primelist)
'''
start = str(input("Let's Start! Enter to continue!"))
while True:
ask = input("Would you like to continue? yes or no?: ")
if ask == "yes":
answer = str(input("Would you like to print a list of all prime numbers from 1 to 100 or enter a number to tell whether it is prime or composite? prime 100/single? prime 100 will print a list of numbers from 1 to 100. Single will ask you for what number do you wan't to be called as prime or composite. "))
if answer == "single" :
num = int(input("Enter the number you want: "))
primenumber(num)
elif answer == "prime 100":
print(primelist)
if ask == "no":
break
ok
It has some things that I will fix and update soon. I will post the updated program later and explain the program though comments.