In recursive algorithms, these are all the cases which are not the base case. These cases serve to reduce the complexity of the problem down towards the base case, then pass along the reduced problem to another copy of the algorithm. In the great trivial recursion algorithm, computing factorials, the recursive case in a problem n! is where n is not equal to 1 or 0; in general, n! == n * (n - 1)!. Here's some code:

#include <stdio.h>
#include <stdlib.h>

int factorial(int n) {
  if (n < 2)  			        /* base case */
  else	                                /* recursive case */
    return(n * factorial(n - 1));

int main(int argc, char *argv[]) {
  printf("%d", factorial(atoi(argv[1])));

This is extra-bad code which will return bad results if given a number bigger than 19 (that's on my x86 -- that number will change on different architectures). Just an example.

Log in or register to write something here or to contact authors.