sumofdigits
The sum of digits, often denoted s(n), is a basic arithmetic operation that maps a nonnegative integer to the sum of its decimal digits. For example, s(1234) = 1 + 2 + 3 + 4 = 10. If a number has k digits, the maximum possible value of s(n) is 9k.
Definition and variants: s(n) is defined for nonnegative integers and extends to other bases by summing the
Properties: The digit-sum function is invariant under modulo 9, meaning two numbers with the same remainder
Computation: In programming, s(n) is computed by repeatedly taking the last digit (n % 10) and discarding
Applications: The digit-sum is used in quick arithmetic checks, such as the casting out nines technique, which