Question: In java please public static long terribleFibonacci (int n) if (n 1) return n; return terribleFibonacci (n -1) + terribleFibonacci (n -2); x * *

In java please public static long terribleFibonacci (int n) if (n 1)In java please

public static long terribleFibonacci (int n) if (n 1) return n; return terribleFibonacci (n -1) + terribleFibonacci (n -2); x * * PROBLEM 4: The impLementation of terribleFibonacci is TERRIBLE! Write a * more efficient version of fibonacci. Do not change runFibonacciLoop or runFibonacciSomeValues * To make fibonacci run faster, you want it so that each call to * fibonacci (n) computes the fibonacci numbers between and n once, not k over and over again. Comment: You will want to use a local variable of type "long" rather than * type "int", for the reasons discussed above. * Comment: At some point, your fibonacci numbers might become negative. * This is normal and expected. * http://en.wikipedia.org/wiki/Integer_overflow We discuss this at length * in our systems classes * You may not use any"fields" to solve this problem (a field is a variable - either before that is declared "outside" of thefunction declaration- * or after). public static void runFibonacciLoop )t for (int N = 0; N

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!