Computer Science, asked by kumarnirmal447, 3 months ago

write a Python program to input a number and check if it is a prime or composite number​

Answers

Answered by roylily1958
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 khushigagain
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