Indirect Recursion
- In Indirect Recursion, there may be more than one function, and they are calling one another in a circular fashion.
- For example, if first function calls second one, second one calls third one and third one calls first one, then it becomes a cycle, so it becomes a Recursion.
void funB(int n);
void funA(int n) {
if (n > 0) {
printf("%d", n);
funB(n - 1);
}
}
void funB(int n) {
if (n > 1) {
printf("%d", n);
funA(n / 2);
}
}
funA(20); // 20 19 9 8 4 3 1