Find the sum of the digits of a given number
A simplified pure numerical function may be:

int digitSum(int input) {
    int n,m,s = input&lt;0 ? -1:1;
    for(n=input*s; n&gt;9; ) {
        for(m=n, n=0; m&gt;0; m/=10)
            n+=m%10;
    }
    return n*s;
}