| 1 | import java.util.*; |
| 2 | class nfibonacci |
| 3 | { |
| 4 | |
| 5 | static int fibo(int n) |
| 6 | { |
| 7 | if(n==0) // base condition; |
| 8 | return 0; |
| 9 | |
| 10 | if(n==1) |
| 11 | return 1; |
| 12 | |
| 13 | //small calculation |
| 14 | int recResult1 = fibo(n-1); |
| 15 | int recResult2 = fibo(n-2); |
| 16 | int smallCal = recResult1+recResult2; |
| 17 | |
| 18 | return smallCal; |
| 19 | |
| 20 | } |
| 21 | |
| 22 | // Driver Code |
| 23 | public static void main(String args[]) |
| 24 | { |
| 25 | Scanner in = new Scanner(System.in); // to take input we use scanner class. |
| 26 | System.out.print("Enter a number : "); |
| 27 | int n = in.nextInt(); |
| 28 | |
| 29 | System.out.println("Fibonacci num of " + n + " is : " + fibo(n)); |
| 30 | } |
| 31 | } |
nothing calls this directly
no outgoing calls
no test coverage detected