write a Python program to input a number and check if it is a prime or composite number
Answers
Answered by
10
Answer:
Other natural numbers that are not prime numbers are called composite numbers. For example: 4, 6, 9 etc. are composite numbers.
...
See this example:
num = int(input("Enter a number: "))
if num > 1:
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
print(i,"times",num//i,"is",num)
break.
else:
Answered by
3
Answer:
num = int(input("Enter a number: "))
if num > 1:
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
print(i,"times",num//i,"is",num)
break
else:
print(num,"is a prime number")
else:
print(num,"is not a prime number")
Similar questions