Answer to Question 17C-3

Observe that factorialTimes(0, m) = m×0! = m. That handles the base case. Now, suppose that n > 0. Then

factorialTimes(n, m)
= m×n!
= m×n×(n−1)!
= factorialTimes(n−1, m×n)
// factorialTimes(n,m) returns m*n!.

long factorialTimes(long n, long m)
{
  if(n == 0)
  {
    return m;
  }
  else
  {
    return factorialTimes(n-1, m*n);
  }
}