Wondering if someone might be able to show me howto set up some recursive Fibona
ID: 3617970 • Letter: W
Question
Wondering if someone might be able to show me howto set up some recursive Fibonacci code, please?public class Fibonacci {
public static long fib(int max)
{
System.out.println("Called Fibonacci (" + max + ")");
long result;
if (max <= 1)
result = 1;
else
result = max-2 + fib(max-1); //PLEASE HELPHERE
System.out.println("Returned Fibonacci (" + max + ") = " +result);
return result;
}
public static void main(String[] args){
System.out.println("Fibonacci Number 5 is " + fib(5));
System.out.println("Fibonacci Number 10 is " + fib(10));
System.out.println("Fibonacci Number 20 is " + fib(20));
System.out.println("Fibonacci Number 15 is " + fib(15));
System.out.println();
}
}
Explanation / Answer
please rate - thanks public class untitled { public static long fib(int max) { System.out.println("CalledFibonacci ("+ max + ")"); long result; if (maxRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.