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

Function solution

project_euler/problem_020/sol3.py:15–38  ·  view source on GitHub ↗

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

(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(1000)
18 10539
19 >>> solution(200)
20 1404
21 >>> solution(100)
22 648
23 >>> solution(50)
24 216
25 >>> solution(10)
26 27
27 >>> solution(5)
28 3
29 >>> solution(3)
30 6
31 >>> solution(2)
32 2
33 >>> solution(1)
34 1
35 >>> solution(0)
36 1
37 """
38 return sum(map(int, str(factorial(num))))
39
40
41if __name__ == "__main__":

Callers 1

sol3.pyFile · 0.70

Calls 1

factorialFunction · 0.90

Tested by

no test coverage detected