Question
The Fibonacci numbers are a famous sequence which shows up in many problems. The sequence, which starts 1, 1, 2, 3, 5, 8, 13, 21,
The Fibonacci numbers are a famous sequence which shows up in many problems. The sequence, which starts 1, 1, 2, 3, 5, 8, 13, 21, 34, ... is computed by setting each term to the sum of the previous two terms. In a recursive definition, we have fib(1) = 1, fib(2) = 1, and fib(n) = fib(n-1) + fib(n-2) in general.
Write a recursive method which computes the n-th Fibonacci number. Use "long" for the return value and write a simple test driver. You should definitely be able to compute fib(25). Even fib(50) might take longer to compute than you're willing to wait.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started