For all representable integral numbers: use recursion.
1 2 3 4 5
int sum_digits( unsignedlonglong number )
{
if( number < 10 ) return number ; // single digit number; return the digit
elsereturn number%10 /* last digit + sum of the other digits */ + sum_digits( number/10 ) ;
}
Depending on how you define "loop".
To rephrase my initial answer, you can't do it without *iteration* of some form, at least not in any way I know of.
you can do it for a subset of all numbers by unrolling the iteration, and for smallish problems, a direct lookup table.