A python program to print Sum of all prime and non prime numbers in a given range
inp = int(input("Enter a positive integer number: "))
is_primes = [] # list of potential prime numbers(contains primes and non primes)
for counting in range(inp):
read = int(input("> "))
is_primes.append(read)
non_primes = []
for number in is_primes:
if number == 2 or number == 3:
pass
else:
for i in range(2, number):
if number % i == 0:
non_primes.append(number)
break
else:
pass
print(sum(non_primes))
Comments
Leave a comment