Sum of Digits
EasyNumbers & Math
The problem
Add up all the digits of a number.
Sample input
12345
Sample output
15Show the solution · 8 languages
fun main() {
var n = 12345
var total = 0
while (n > 0) {
total += n % 10
n /= 10
}
println(total)
}