CS210 Lab: Recursion Postlab


Postlab Exercise:

Use the following function to answer Questions 1 and 2.
int Puzzle (int base, int limit)
{
	if (base > limit)
		return -1;
	else
		if (base == limit)
			return 1;
		else
			return base* Puzzle(base+1, limit);
}
  1. Identify the following:
    1. the base case(s) of the function Puzzle
    2. the general (recursive) case(s) of the function Puzzle

  2. Show what would be written by the following calls to the recursive function Puzzle
    1. cout << Puzzle(20,5);
    2. cout << Puzzle(3,6);
    3. cout << Puzzle(8,8);
Answer for post lab
Back to Recursion Lab click here

CS Dept Home Page
CS Dept Class Files
CS210 Class Files

Copyright: Department of Computer Science, University of Regina.