how to Calculate sum of digits of a number in single Statement???

might help if I knew what language you are using?

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()))`

1 Like

Sum of digits of a no. till we get a single digit (Lang. - C):

(n 9) ? (n 9) : 9 ;

2 Likes

sumDig is initialised with num%10

while (num/=10) sumDig += num%10;