solutions.problem10.solve()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 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`.
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (112/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
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
0 ignored issues
show
Coding Style Naming introduced by
The name expected_answer does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
42