Example: Computing Quotients
- Problem: Use recursion to compute the
quotient of a number and a divisor.
- (quot n d) should give the number of
times d divides n.
Expression | Value
|
(quot 9 3) | 3
|
(quot 10 3) | 3
|
(quot 11 3) | 3
|
(quot 12 3) | 4
|
- Assume initially that
n and d are both
positive.
- Q: What is the base case?
- Q: What is the self-similar sub-problem?