suma de digitos

Solutions on MaxInterview for suma de digitos by the best coders in the world

showing results for - "suma de digitos"
Michelle
06 May 2017
1//Recursive function to find sum of digits of a number
2int sumOfDigits(int num){
3    // Base condition
4    if(num == 0){
5        return 0;
6    }
7
8    return ((num % 10) + sumOfDigits(num / 10));
9}