sum of prime numbers python

Solutions on MaxInterview for sum of prime numbers python by the best coders in the world

showing results for - "sum of prime numbers python"
Anthony
02 Aug 2016
1ending_range = int(input("Find sum of prime numbers upto : "))
2
3total = 0
4
5for num in range(2, ending_range + 1):
6
7    i = 2
8    
9    for i in range(2, num):
10        if (int(num % i) == 0):
11            i = num
12            break;
13
14    #If the number is prime then add it.
15    if i is not num:
16        total += num
17
18print("\nSum of all prime numbers till", ending_range, ":", total)