The Fibonacci sequence is defined as follows:
Position | Fib Number |
---|---|
0 | 0 |
1 | 1 |
2 | 1 |
3 | 2 |
4 | 3 |
5 | 5 |
6 | 8 |
7 | 13 |
8 | 21 |
etc. | etc. |
Positions 0 & 1 are definition values. For positions greater than 1, the corresponding Fibonacci value of position
N = Fib (N-1) + Fib (N-2)
.
Bonus: Using a return type of int, find the highest Fibonacci number Java can compute on a PC. After finding it, what happens when you try to compute the next Fibonacci number? What's going on?? Can you show exactly how Java got its answer? If you're stuck, the answer lies within Lesson 3, page B.
Use these sample run output values:
Recursive Fibonacci: 0, 3, 11, 20
Recursive multiplication 1: (7 * 8), (5 * 1), (5 * 0), (0 * 9), (0 * 0), (45 * 11)
Recursive multiplication 2: (-7 * 8), (-7 * -8), (7 * -8), (-7 * 9), (-7 * -9), (7 * -9)
Format your output so it looks something like this:
Fib(0) = 0
Fib(3) = 2
...
7*8 = 56
5*1 = 5
5*0 = 0
...
All files must include your name and period in the right format. For example,
P3_Wang_Michael_Fibonacci.java
Same with the driver.
You must Sign In to submit to this assignment
Last modified: December 12, 2022
Back to SummaryDark Mode
Outline