All problems
Sum of Primes Below N
Problem
Return the sum of all prime numbers strictly less than n.
Use the sieve of Eratosthenes for values below n and sum the numbers still marked prime. Return 0 for n < 3.
Hint
2 + 3 + 5 + 7 equals 17, the sum of primes below 10.
Test cases
case 1
in: [10]
expected: 17
case 2
in: [2]
expected: 0
case 3
in: [0]
expected: 0
case 4
in: [100]
expected: 1060
case 5
in: [1]
expected: 0
case 6
in: [1000]
expected: 76127
Starter codePython
def sum_primes_below(n):
# Your code here
pass6 test cases · run your code against them in the editor