how to Calculate sum of digits of a number in single Statement???
I know how to do it in python;
let’s assume the number is stored in a variable called num
print sum(map(int,' '.join(str(num)).split()))
Sum of digits of a no. till we get a single digit (Lang. - C):
(n % 9) ? (n % 9) : 9 ;
sumDig is initialised with num%10
while (num/=10) sumDig += num%10;
might help if I knew what language you are using?