MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_020/sol1.py:31–50  ·  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

29
30
31def solution(num: int = 100) -> int:
32 """Returns the sum of the digits in the factorial of num
33 >>> solution(100)
34 648
35 >>> solution(50)
36 216
37 >>> solution(10)
38 27
39 >>> solution(5)
40 3
41 >>> solution(3)
42 6
43 >>> solution(2)
44 2
45 >>> solution(1)
46 1
47 """
48 nfact = factorial(num)
49 result = split_and_add(nfact)
50 return result
51
52
53if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls 2

split_and_addFunction · 0.85
factorialFunction · 0.70

Tested by

no test coverage detected