Write a program to print the sum of non-primes in the given N numbers. The numbers which are not primes are considered as non-primes.
Input
The first line of input will contain a positive integer (N).
The following N lines will contain an integer in each line.
Output
The output should be the sum of non-primes in the given numbers.
Sample Input 1
5
8
11
96
49
25
Sample Output 1
178
def check_noprimes(number):
number = abs(number)
for item in range(2,number):
if number % item == 0:
return True
return False
# input count number
count = int(input())
user_list =[]
result = 0
# input list number
for item in range(count):
user_list.append(int(input()))
for item in user_list:
if check_noprimes(item):
result += item
print(result)
Comments
Leave a comment