solutions.problem3   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A solve() 0 6 1
1
"""
2
Project Euler Problem 3: Largest Prime Factor
3
=============================================
4
5
.. module:: solutions.problem3
6
   :synopsis: My solution to problem #3.
7
8
The source code for this problem can be
9
`found here <https://bitbucket.org/nekedome/project-euler/src/master/solutions/problem3.py>`_.
10
11
Problem Statement
12
#################
13
14
The prime factors of :math:`13195` are :math:`5,7,13` and :math:`29`.
15
16
What is the largest prime factor of the number :math:`600851475143`?
17
18
Solution Discussion
19
###################
20
21
Factor the number :math:`600851475143` and then find the largest prime factor.
22
23
Solution Implementation
24
#######################
25
26
.. literalinclude:: ../../solutions/problem3.py
27
   :language: python
28
   :lines: 31-
29
"""
30
31
from lib.numbertheory import factor
32
33
34
def solve():
35
    """ Compute the answer to Project Euler's problem #3 """
36
    target = 600851475143
37
    factors = factor(target)
38
    answer = max(factors.keys())  # factors = {prime: power}
39
    return answer
40
41
42
expected_answer = 6857
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...
43