Digit Sum

Given a non-negative integer n, go through its digits and add them together. This kind of operation appears in checks, games, and simple number algorithms. Return the total sum.

Примеры

Ввод
12345
Вывод
15
Ввод
0
Вывод
0
Ввод
999
Вывод
27

Нужно реализовать

def sum_of_digits(n: int) -> int:

Теги

math
PostgreSQLv16

Här visas resultatet av din kod

Visible tests
1
Input
12345
Expected15
2
Input
0
Expected0
3
Input
999
Expected27
4
Input
100
Expected1
5
Input
1000
Expected1
6
Input
1
Expected1
Focus radio
Paused · SomaFM · Fluid