= Digit sum
{title2=$s_b(n)$}
{wiki}
= Digital sum
{synonym}
= Sum of digits
{synonym}
The <digit sum> of a <nonnegative integer> in a specified <radix> is the sum of its <numerical digits>. If
$$
n=\sum_{j=0}^{k-1}d_jb^j,\qquad 0\le d_j<b,
$$
write $s_b(n)=\sum_jd_j$, with $s_b(0)=0$. For example, $s_{10}(347)=3+4+7=14$. In <binary representation>, the <digit sum> is the <Hamming weight> of the digit string.
Since $b\equiv1\pmod{b-1}$, the positional expansion gives
$$
n\equiv s_b(n)\pmod{b-1}.
$$
In <decimal representation>, this yields the familiar <divisibility> tests by $3$ and $9$: the <integer> and its <digit sum> have the same <remainder> <modulo> either. For $347$, both $347$ and $14$ leave remainder $5$ <modulo> $9$. The argument explains the rule from <modular arithmetic>, rather than relying on a pattern noticed in examples.
Back to article page