Recursion is a powerful tool, but it can be tricky to get right. Getting it wrong can lead to stack overflow errors and cause system problems. Even
when you do get it right, recursive code can be difficult to understand, perhaps leading to maintenance problems in the future. Therefore recursion
should be avoided in general and used only with due deliberation and caution when it is strictly necessary.

This rule checks for direct recursion (when a function calls itself).

## Noncompliant Code Example

int pow(int num, int exponent) {
if (exponent > 1) {
num = num * pow(num, exponent-1); // Noncompliant; direct recursion
}
return num;
}

## Compliant Solution

int pow(int num, int exponent) {
int val = num;
while (exponent > 0) {
val *= num;
--exponent;
}
return val;
}

## See

- MISRA C:2004, 16.2 - Functions shall not call themselves, either directly or indirectly.
- MISRA C++:2008, 7-5-4 - Functions should not call themselves, either directly or indirectly.
- MISRA C:2012, 17.2 - Functions shall not call themselves, either directly or indirectly