ITPEC FE Morning April 2018 Question 7
ITPEC FE Morning April 2018 — Question 7 of 80
Recursive Factorial — identifying the correct recursive expression for computing n!.
The factorial function is defined as:
- F(0) = 1 (base case)
- F(n) = n × F(n − 1) for n > 0
Verification: F(3) = 3 × F(2) = 3 × 2 × F(1) = 3 × 2 × 1 × F(0) = 3 × 2 × 1 × 1 = 6 ✓
Why not others:
- (a) n + F(n - 1) — uses addition instead of multiplication, producing a sum (triangular numbers), not a factorial.
- (b) n - 1 + F(n) — calls F(n) inside the definition of F(n), causing infinite recursion with no progress toward the base case.
- (d) (n - 1) × F(n) — also calls F(n) inside itself, causing infinite recursion.
Key rule: Factorial is defined by n × (n − 1)!, so the recursive call must reduce the argument toward the base case.
AI-generated — may contain errors
The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.