0% found this document useful (0 votes)
24 views3 pages

Fibonacci Number HW

The document discusses enhancing a Fibonacci program to calculate the approximate time required to perform Fibonacci number calculations and the number of recursive calls made. It describes adding methods to track start and end times of calculations in milliseconds and count recursive calls, and outputting the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Fibonacci Number HW

The document discusses enhancing a Fibonacci program to calculate the approximate time required to perform Fibonacci number calculations and the number of recursive calls made. It describes adding methods to track start and end times of calculations in milliseconds and count recursive calls, and outputting the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Home Work

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)

You might also like