Fibonacci Number HW
Fibonacci Number HW
due 04.24.2020
1. (Time to Calculate Fibonacci Numbers) Enhance the
Fibonacci program ,so that it calculates the
approximate amount of time required to perform the
calculation and the number of calls made to the
recursive method. For this purpose, call static System
method currentTimeMills, which takes no arguments
and returns the computer’s current time in
milliseconds. Call this method twice- once before and
once after the call to fibonacci. Save each value and
calculate the difference in the times to determine how
many milloseconds were required to perform the
calculation. Then,add a variable to the
FibonacciCalculate class, and use this variable to
determine the number of calls made to method
fibonacci. Display you results.
run:
Fibonacci of 0 is: 0
took 0 milliseconds
took 1 recursive calls
Fibonacci of 1 is: 1
took 0 milliseconds
took 1 recursive calls
Fibonacci of 2 is: 1
took 0 milliseconds
took 3 recursive calls
Fibonacci of 3 is: 2
took 0 milliseconds
took 5 recursive calls
Fibonacci of 4 is: 3
took 0 milliseconds
took 9 recursive calls
Fibonacci of 5 is: 5
took 0 milliseconds
took 15 recursive calls
Fibonacci of 6 is: 8
took 0 milliseconds
took 25 recursive calls
Fibonacci of 7 is: 13
took 0 milliseconds
took 41 recursive calls
Fibonacci of 8 is: 21
took 0 milliseconds
took 67 recursive calls
Fibonacci of 9 is: 34
took 0 milliseconds
took 109 recursive calls
Fibonacci of 10 is: 55
took 0 milliseconds
took 177 recursive calls
BUILD SUCCESSFUL (total time: 7 seconds)