Sichanov

Untitled

Aug 8th, 2021
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. n = input()
  2. prime_sum = 0
  3. non_prime_sum = 0
  4.  
  5. while n != 'stop':
  6. n = int(n)
  7. if int(n) % 2 != 0:
  8. prime_sum += int(n)
  9. if n == 'stop':
  10. break
  11.  
  12. elif int(n) % 2 == 0:
  13. non_prime_sum += int(n)
  14. if n == 'stop':
  15. break
  16. n = input()
  17. if n < 0:
  18. print(f'Number is negative.')
  19.  
  20. print(f'Sum of all prime numbers is: {prime_sum}')
  21. print(f'Sum of all non prime numbers is: {non_prime_sum}')
Advertisement
Add Comment
Please, Sign In to add comment