Writing a recursive function
Introduction
Example: The factorial function.
unsigned int factorial(unsigned int n){
unsigned int rc = 1 ; //base case result
if(n > 1) //if n > 1 we have the recursive case
rc= n * factorial(n-1); //rc is n * (n-1)!
}
return rc;
}Last updated