Returns the sum of all the primes below n. >>> solution(1000) 76127 >>> solution(5000) 1548136 >>> solution(10000) 5736396 >>> solution(7) 10
(n: int = 2000000)
| 63 | |
| 64 | |
| 65 | def solution(n: int = 2000000) -> int: |
| 66 | """ |
| 67 | Returns the sum of all the primes below n. |
| 68 | |
| 69 | >>> solution(1000) |
| 70 | 76127 |
| 71 | >>> solution(5000) |
| 72 | 1548136 |
| 73 | >>> solution(10000) |
| 74 | 5736396 |
| 75 | >>> solution(7) |
| 76 | 10 |
| 77 | """ |
| 78 | |
| 79 | return sum(takewhile(lambda x: x < n, prime_generator())) |
| 80 | |
| 81 | |
| 82 | if __name__ == "__main__": |
no test coverage detected