For example, if the given number is 5, then read the inputs in the next 5 lines and print the sum of non-primes in the given five numbers. If the given input integers in the next five lines are 8, 11, 96, 49, and 25 the output should be 8 + 96 + 49 + 25 is 178.
n = int(input())
numbers = []
for i in range(n):
number = int(input())
isPrime=True
if number > 1:
#Check if number if prime
for j in range(2, number):
if (number % j) == 0:
isPrime=False
break
if isPrime==False:
numbers.append(number)
print(sum(numbers))
Comments
Leave a comment