| Total Complexity | 1 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |
||
|
|
|||
| 43 |
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.