/* Problem Description : Given a number A, find and return the Ath Fibonacci Number using recursion.
Given that F0 = 0 and F1 = 1.
Problem Constraints : 0 <= A <= 20 */
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
public static int findAthFibonacci(int A) {
// Base Logic
if (A == 0 || A == 1) {
return A;
}
return findAthFibonacci(A - 1) + findAthFibonacci(A - 2); // Main logic, fun calling itself
}
public static void main(String[] args) {
int n = 9;
Main main = new Main();
int res = main.findAthFibonacci(n);
System.out.println("The " + n + "-th Fibonacci number is: " + res);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: