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

Function split_and_add

project_euler/problem_020/sol1.py:21–28  ·  view source on GitHub ↗

Split number digits and add them.

(number: int)

Source from the content-addressed store, hash-verified

19
20
21def split_and_add(number: int) -> int:
22 """Split number digits and add them."""
23 sum_of_digits = 0
24 while number > 0:
25 last_digit = number % 10
26 sum_of_digits += last_digit
27 number = number // 10 # Removing the last_digit from the given number
28 return sum_of_digits
29
30
31def solution(num: int = 100) -> int:

Callers 1

solutionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected