Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please send code Have you ever wondered if you can quantify the reproduction of

ID: 3774632 • Letter: P

Question

please send code

Have you ever wondered if you can quantify the reproduction of rabbits in the wild? In the 13th century a famous Italian Mathematician Leonardo Bonacci, known commonly as Fibonacci, wrote a book including this example. Under certain idealistic assumptions, his results were that if we start with one pair of rabbits, then the number of pairs of rabbits after N breeding seasons, equals the number of pairs of rabbits after N-l breeding seasons plus the number of pairs of rabbits after N-2 breeding seasons. So in season 1 we have 1 pair; season 2 we have 0+1=1 pair Season 3; we have 1+1=2 pairs Season 4; we have 1+2=3 pairs, etc...Thus let Fibonacci(N) denote the number of pairs in the Nth breeding season. Then, Fibonacci(N)= Fibonacci(N-l) +Fibonacci(N-2) Of course we have two base cases, Fibonacci(0)=0, and Fibonacci(l)=l Create a project in Java called Fibonacci Add a class with main. Implement a function, int Fibonacci (int N), in Java, and define it recursively so It satisfies the above recursion. It should have the following form int Fibonacci (int N){if(N==0){return some integer}else if (N==l){return some integer}else{use the recursion above to return something in terms of the Fibonacci function.}

Explanation / Answer

public class Fibonacci {
  
public static void main(String arg[]) {
//calculate fib for value 10
System.out.println(fibonacci(10));
}
  
public static int fibonacci(int val){
if(val == 0)
return 0;
else if(val == 1)
return 1;
else
return fibonacci(val-1) + fibonacci(val-2);   
}
}