Practice ยท 4 of 4
Digit sum loop
CHALLENGE
Difficulty: beginner+25 XP
Implement static int DigitSum(int n) โ sum of the decimal digits of n's absolute value. DigitSum(0) is 0; DigitSum(-907) is 16. No string conversion: use % and / in a loop.
Press Submit to check your solution.
Back to lesson: Practice: Flow under pressure