Recursion and Factorials
- 15Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is recursion in computer science?
15 questions
- 1
What is recursion in computer science?
Model answer
Recursion is a way of solving a problem by having a function call itself.
Explanation
A recursive solution uses a function’s self-call as part of solving the problem.
- 2
What is the purpose of the proposed
factfunction, and what does it take as input?Model answer
It takes a nonnegative integer as input and returns that integer’s factorial.
Explanation
The function is intended to calculate n! for a positive integer or zero.
- 3
How can recognizing a smaller factorial within the definition of n! help create a recursive solution?
Model answer
The product after the first n is (n−1)!, so for n≥1, n! can be written as n(n−1)!.
Explanation
This expresses the factorial of n in terms of the factorial of a smaller number.
- 4
Why is a recursive factorial definition incomplete if it only states n!=n(n−1)!?
Model answer
It needs a separate case for n=0, because applying the rule there requires (−1)!, which is undefined.
Explanation
A recursive definition must account for the point where the general rule cannot be applied.
- 5
What role does the case 0!=1 play in the complete recursive definition of factorial?
Model answer
It provides the defined result for zero and completes the factorial definition for all nonnegative integers.
Explanation
The recursive rule applies for n≥1; the zero case supplies the separate endpoint.
- 6
How is n! defined as a product for a positive integer n?
Model answer
It is the product of the positive integers from n down to 1: n!=n(n−1)(n−2)⋯2⋅1.
Explanation
The definition multiplies each successive integer down to one.
- 7
Calculate 4! using the product definition.
Model answer
4!=4⋅3⋅2⋅1=24.
Explanation
Multiplying the integers from four down to one gives twenty-four.
- 8
Calculate 2! using the product definition.
Model answer
2!=2⋅1=2.
Explanation
The product from two down to one is two.
- 9
What is the value of 1!?
Model answer
1!=1.
Explanation
The product definition for one gives a value of one.
- 10
What is the value of 0!, and how is it established in the content?
Model answer
0!=1; it is defined to be one.
Explanation
The zero factorial is given as a definition rather than calculated using the positive-integer product.
- 11
For which values of n does the rule n!=n(n−1)! apply?
Model answer
It applies when n≥1.
Explanation
At n=0, the rule would require (−1)!, so the rule is restricted to positive integers.
- 12
How does the recursive rule correctly evaluate 2!?
Model answer
2!=2⋅1!=2⋅1=2.
Explanation
The rule reduces 2! to 1!, whose value is one.
- 13
How does the recursive rule correctly evaluate 1!?
Model answer
1!=1⋅0!=1⋅1=1.
Explanation
The rule reduces 1! to the defined value of 0!.
- 14
State the complete recursive definition of factorial for nonnegative integers.
Model answer
n!=n(n−1)! if n≥1, and 0!=1.
Explanation
The recursive rule covers positive integers, while the separate zero case completes the definition.
- 15
Use the recursive definition to calculate 3!.
Model answer
3!=3⋅2!=3⋅2=6.
Explanation
Applying the rule reduces 3! to 2!, whose value is two.

Ask anything
We've read this whole study set, so questions about it get the best answers.