| Total Complexity | 1 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """ |
||
| 2 | Project Euler Problem 10: Summation Of Primes |
||
| 3 | ============================================= |
||
| 4 | |||
| 5 | .. module:: solutions.problem10 |
||
| 6 | :synopsis: My solution to problem #10. |
||
| 7 | |||
| 8 | The source code for this problem can be |
||
| 9 | `found here <https://bitbucket.org/nekedome/project-euler/src/master/solutions/problem10.py>`_. |
||
| 10 | |||
| 11 | Problem Statement |
||
| 12 | ################# |
||
| 13 | |||
| 14 | The sum of the primes below :math:`10` is :math:`2 + 3 + 5 + 7 = 17`. |
||
| 15 | |||
| 16 | Find the sum of all the primes below two million. |
||
| 17 | |||
| 18 | Solution Discussion |
||
| 19 | ################### |
||
| 20 | |||
| 21 | Simply accumulate the sum of primes up to the limit. Iterating over primes is off-loaded to :mod:`lib.sequence`. |
||
|
|
|||
| 22 | |||
| 23 | Solution Implementation |
||
| 24 | ####################### |
||
| 25 | |||
| 26 | .. literalinclude:: ../../solutions/problem10.py |
||
| 27 | :language: python |
||
| 28 | :lines: 31- |
||
| 29 | """ |
||
| 30 | |||
| 31 | from lib.sequence import Primes |
||
| 32 | |||
| 33 | |||
| 34 | def solve(): |
||
| 35 | """ Compute the answer to Project Euler's problem #10 """ |
||
| 36 | target = 2000000 |
||
| 37 | answer = sum(Primes(upper_bound=target)) |
||
| 38 | return answer |
||
| 39 | |||
| 40 | |||
| 41 | expected_answer = 142913828922 |
||
| 42 |
This check looks for lines that are too long. You can specify the maximum line length.