Answers for "sum of prime numbers python"

1

sum of prime numbers python

ending_range = int(input("Find sum of prime numbers upto : "))

total = 0

for num in range(2, ending_range + 1):

    i = 2
    
    for i in range(2, num):
        if (int(num % i) == 0):
            i = num
            break;

    #If the number is prime then add it.
    if i is not num:
        total += num

print("\nSum of all prime numbers till", ending_range, ":", total)
Posted by: Guest on August-25-2021

Python Answers by Framework

Browse Popular Code Answers by Language