Write a public static method named static long fibfastint n


Programming langauge is JAVA:

Write a public static method named static long fibFast(int n, long a, long b) that returns the nth fibonacci number. The method should be coded as follows:

If n is zero then just return a (the zeroth fibonacci number).

If n > 0 call the function recursively with n-1 as the first parameter , b as the second parameter and a+b as the last parameter .

Effecfively, we are creating a loop in which a and b represent two consecutive fibonacci numbers. As n goes down by 1 we replace those by the next consecutive pair of Fibonacci numbers.

Eventually n reaches 0 and the first parameter will equal the nth fibonacci number.

Note: this only works if the initial call is fibFast(n, 0, 1).

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a public static method named static long fibfastint n
Reference No:- TGS02902659

Expected delivery within 24 Hours