PRIME NUMBERS: Numbers are which are divisible by one and itself only are called prime numbers
COMPOSITE NUMBERS: Numbers which are not prime are called composite numbers
INPUT :
enter the numbers 2 3 4 5 6
OUTPUT :
2 is even prime
prime numbers are
3
5
composite numbers are
4
6
PROGRAM :
composite_list = []
prime_list = []
l = list(map(int,input('enter the numbers:').strip().split(' ')))
for i in list(l):
if(i == 2):
print('2 is even prime')
else:
flag = 0
for j in range(2, i):
if (i % j == 0):
flag = 1
if (flag == 0):
prime_list.append(i)
else:
composite_list.append(i)
jk = len(prime_list)
kj = len(composite_list)
if(jk == 0):
print('there are no prime numbers')
else:
print('prime number are')
for k in list(prime_list):
print(k)
if(kj == 0):
print('there are no composite numbers')
else:
print('composite numbers are')
for p in list(composite_list):
print(p)
CLICK HERE TO RUN THE PYTHON CODE
copyright© to jagadeesh
Post a Comment