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)
Comments
Leave a comment