Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = input()
- prime_sum = 0
- non_prime_sum = 0
- not_prime = False
- while n != "stop":
- n = int(n)
- if n < 0:
- print("Number is negative.")
- n = input()
- continue
- else:
- for i in range(2, n):
- if n % i == 0:
- not_prime = True
- break
- if not_prime:
- non_prime_sum += n
- not_prime = False
- else:
- prime_sum += n
- n = input()
- print(f"Sum of all prime numbers is: {prime_sum}")
- print(f"Sum of all non prime numbers is: {non_prime_sum}")
Advertisement
Add Comment
Please, Sign In to add comment