digit_sum(n) that returns the sum of the digits of a non-negative integer n, using a while loop and integer arithmetic (% 10 and // 10) — not string conversion.digit_sum(1234)
10
1+2+3+4 = 10.
digit_sum(7)
7
Single digit sums to itself.
digit_sum(0)
0
Zero has digit sum zero.
`n % 10` gives the last digit; `n // 10` drops it.
Loop while n is greater than 0 (handle the n == 0 case separately or as a special starting check).