Issues (956)

solutions/problem20.py (3 issues)

1
"""
2
Project Euler Problem 20: Factorial Digit Sum
3
=============================================
4
5
.. module:: solutions.problem20
6
   :synopsis: My solution to problem #20.
7
8
The source code for this problem can be
9
`found here <https://bitbucket.org/nekedome/project-euler/src/master/solutions/problem20.py>`_.
10
11
Problem Statement
12
#################
13
14
:math:`n!` means :math:`n \\times (n - 1) \\times \\dots \\times 3 \\times 2 \\times 1`
15
16
| For example, :math:`10! = 10 \\times 9 \\times \\dots \\times 3 \\times 2 \\times 1 = 3628800`,
17
| and the sum of the digits in the number :math:`10!` is :math:`3 + 6 + 2 + 8 + 8 + 0 + 0 = 27`.
18
19
Find the sum of the digits in the number :math:`100!`
20
21
Solution Discussion
22
###################
23
24
Build the value of :math:`100!` using Python's arbitrary precision arithmetic and then perform a decimal digit sum on
0 ignored issues
show
This line is too long as per the coding-style (117/100).

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

Loading history...
25
that result.
26
27
Solution Implementation
28
#######################
29
30
.. literalinclude:: ../../solutions/problem20.py
31
   :language: python
32
   :lines: 35-
33
"""
34
35
from lib.digital import digit_sum
36
from lib.sequence import Factorials
37
38
39
def solve():
40
    """ Compute the answer to Project Euler's problem #20 """
41
    target = 100
42
    factorials = Factorials()
43
    x = factorials[target]
0 ignored issues
show
Coding Style Naming introduced by
The name x does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[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...
44
    answer = digit_sum(x)
45
    return answer
46
47
48
expected_answer = 648
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...
49