algorithms/recursion/recursive-digit-sum.c
int superDigit(char* n, int k) {
    long sum = 0;
    for (int i = 0; n[i]; i++) {
        sum += (long)(n[i] - '0');
    }
    sum *= k;
    for (;;) {
        long tmp = 0;
        while (sum > 0) {
            tmp += sum % 10;
            sum /= 10;
        }
        if (tmp < 10) {
            return tmp;
        }
        sum = tmp;
    }
}
/*
 * Complete the 'superDigit' function below.
 *
 * The function is expected to return an INTEGER.
 * The function accepts following parameters:
 *  1. STRING n
 *  2. INTEGER k
 */
Complete the 'superDigit' function below.
The function is expected to return an INTEGER.
The function accepts following parameters:
1. STRING n
2. INTEGER k
Complete the ' superDigit ' function below . The function is expected to return an INTEGER . The function accepts following parameters : 1 . STRING n 2 . INTEGER k
int superDigit(char* n, int k) {
    long sum = 0;
    for (int i = 0; n[i]; i++) {
        sum += (long)(n[i] - '0');
    }
    sum *= k;
    for (;;) {
        long tmp = 0;
        while (sum > 0) {
            tmp += sum % 10;
            sum /= 10;
        }
        if (tmp < 10) {
            return tmp;
        }
        sum = tmp;
    }
}
int superDigit ( char * n , int k ) { long sum = 0 ; for ( int i = 0 ; n [ i ] ; i ++ ) { sum += ( long ) ( n [ i ] - ' ' ) ; } sum *= k ; for ( ; ; ) { long tmp = 0 ; while ( sum > 0 ) { tmp += sum % 10 ; sum /= 10 ; } if ( tmp < 10 ) { return tmp ; } sum = tmp ; } }
Complete the 'superDigit' function below.
Complete the ' superDigit ' function below .