Digital root
C++ Loops
nested loops
Flowchart (ISO 5807)
Source code
int digitalRoot(int n) {
while (n >= 10) {
int s = 0;
while (n > 0) {
s += n % 10;
n /= 10;
}
n = s;
}
return n;
}