Hi all!
I need help again. Thanks to those who replied on my recursion question. But now I've got bigger fish to fry.
I have to write a nonrecursive method that computes Fibonacci numbers.
The person is suppose to input an index and the application is suppose to compute what Fibonacci number is at that index. The algorithm my text gives me is a follows:
public static long fib(long q) { //I've added this line
f0 = 0;
f1 = 1;
for (int r = 2; r <= q; r++) {
currentFib = f0 + f1;
f0 = f1;
f1 = currentFib;
I've got everything set up accept for the acutal formula to compute. I don't know if I should be using a return statement, if statement or what. I'm still unclear as to exactly how this calculation works. Can somebody please help
I'm dying here!
Thanks
Stacey