Recursion and Factorials
- 15Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What does the factorial n! represent for a positive integer n?
The product of all positive integers from n down to 1.
Or swipe the card
15 cards
What does the factorial n! represent for a positive integer n?
The product of all positive integers from n down to 1.
What is 4!?
24
What is 2!?
2
What is 1!?
1
What is 0!?
1
How can the terms after the leading n in the factorial product be rewritten?
They equal (n−1)!, so n!=n(n−1)! for n≥1.
For which values of n does the relation n!=n(n−1)! work?
It works for integers n≥1.
Why can’t n!=n(n−1)! be used at n=0?
It would require (−1)!, which is not defined.
What two cases give a complete recursive definition of factorial for nonnegative integers?
n!=n(n−1)! when n≥1, and 0!=1.
Why is the formula n!=n(n−1)! alone an incomplete definition of factorial?
It does not define the value at n=0.
What is recursion in computer science?
A way to solve a problem by having a function call itself.
What is the purpose of a function named
factin the factorial example?It takes a nonnegative integer as input and returns that integer’s factorial.
What is the recursive case for calculating factorial with a function?
For n≥1, return n multiplied by the factorial of n−1.
What is the base case for a recursive factorial function?
When the input is 0, return 1.
Using the recursive definition, what is 3!?
6

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