Returns the sum of the digits of the number. >>> digit_sum(123) 6 >>> digit_sum(456) 15 >>> digit_sum(78910) 25
(n: int)
| 14 | |
| 15 | |
| 16 | def digit_sum(n: int) -> int: |
| 17 | """ |
| 18 | Returns the sum of the digits of the number. |
| 19 | >>> digit_sum(123) |
| 20 | 6 |
| 21 | >>> digit_sum(456) |
| 22 | 15 |
| 23 | >>> digit_sum(78910) |
| 24 | 25 |
| 25 | """ |
| 26 | return sum(int(digit) for digit in str(n)) |
| 27 | |
| 28 | |
| 29 | def solution(n: int = 30) -> int: |