Write a recursive Java method to compute the nth term of the Fibonacci sequence, taking the first two terms as 0 and 1.
Recursion
Original Khojo Papers practice question — not from a past board paper.
int fact(int n) { if (n == 0) return 1; else return n * fact(n - 1); }
No citable source has been recorded for this record. Treat it as practice material, not as fact.
The base case n = 0 is essential; without it the recursion would never terminate and the stack would overflow.
From the same topic and chapter, at a similar level.
Write a recursive Java method to compute the nth term of the Fibonacci sequence, taking the first two terms as 0 and 1.
Recursion
Write a recursive Java method to find the greatest common divisor of two positive integers.
Recursion
How many times is the method called in total when fact(5) is executed, taking fact(0) as the base case?
Recursion
State two advantages and two disadvantages of recursion compared with iteration.
Recursion
Write a recursive Java method to reverse a string.
Recursion
Reduce F(A, B, C) = Σ(0, 1, 2, 3) using a Karnaugh map.
Karnaugh Maps