MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_020/sol2.py:15–32  ·  view source on GitHub ↗

Returns the sum of the digits in the factorial of num >>> solution(100) 648 >>> solution(50) 216 >>> solution(10) 27 >>> solution(5) 3 >>> solution(3) 6 >>> solution(2) 2 >>> solution(1) 1

(num: int = 100)

Source from the content-addressed store, hash-verified

13
14
15def solution(num: int = 100) -> int:
16 """Returns the sum of the digits in the factorial of num
17 >>> solution(100)
18 648
19 >>> solution(50)
20 216
21 >>> solution(10)
22 27
23 >>> solution(5)
24 3
25 >>> solution(3)
26 6
27 >>> solution(2)
28 2
29 >>> solution(1)
30 1
31 """
32 return sum(int(x) for x in str(factorial(num)))
33
34
35if __name__ == "__main__":

Callers 1

sol2.pyFile · 0.70

Calls 1

factorialFunction · 0.90

Tested by

no test coverage detected