Answer to Question #182743 in Python for Prashanth

Question #182743

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




1
Expert's answer
2021-04-18T08:39:34-0400
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS