You are viewing a single comment's thread. Return to all comments →
long tinhTong(string n) { long sum = 0;
for (int i = 0; i < n.length(); ++i) { sum += 1ll * (n[i] - '0'); } return sum;
}
long superDigit(string n, int k) { long N = tinhTong(n) * k;
while (N >= 10) { long sum = 0; while (N) { sum += (N % 10); N /= 10; } N = sum; } return N;
Seems like cookies are disabled on this browser, please enable them to open this website
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
long tinhTong(string n) { long sum = 0;
}
long superDigit(string n, int k) { long N = tinhTong(n) * k;
}