Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.codewithDZM;
- import java.util.*;
- public static int fibonacci (int n)
- {
- if (n<2)
- {
- return n;
- }
- else
- return ( (fibonacci (n-1) ) + ( fibonacci (n-2) ) );
- }
- public class Main
- {
- public static void main(String[] args)
- {
- int x;
- Scanner sc = new Scanner (System.in);
- System.out.println ( fibonacci (x) );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement