Answer to Question #220311 in Python for Rubiya

Question #220311
Write python program
To print sum of non primes In the given N numbers.the numbers which are not primes considered as non primes in nested loops topic..
The first line of input will contain
positive integer (N).
The following N lines will contain an integer in each line.
1
Expert's answer
2021-07-25T08:38:39-0400
def nonprime(m):
    ans = True
    for i in range(2, m):
        if(m%i == 0):
            ans = False;
            break;
    return ans


n = int(input("Enter a 5 digit number : "))
sum =0
while(n>0):
    rem = n%10
    n = n//10
    k = nonprime(rem)
    if(k == True):
        continue
    else:
        sum = sum + rem


print("Sum of non prime numbers is : ",sum)

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
APPROVED BY CLIENTS