- There must be a solveable problem.
- There must be a terminating clause.
Factorials are often cited as a classic example of using recursion.
The factorial f(n) = n * (n-1) * (n-2) * .. 1.
For example factorial 5 (written as 5!) = 5 x 4 x 3 x 2 x 1 = 120. The function below returns the factorial of the parameter n.
int factorial( int n) {
if (n==1)
return 1
else
return n* factorial( n-1) ;
}
int value=factorial(6) ;
Glossary:
A B C D E F G H I J K L M N O P Q R S T U V W X Y ZA classic, albeit not very funny definition of recursion is given as a dictionary entry :
Recursion [n] : See Recursion.

