Check out example codes for "suma de digitos". It will help you in understanding the concepts better.

Code Example 1

//Recursive function to find sum of digits of a number
int sumOfDigits(int num){
    // Base condition
    if(num == 0){
        return 0;
    }

    return ((num % 10) + sumOfDigits(num / 10));
}

Learn ReactJs, React Native from akashmittal.com