SHARE
TWEET

Fibonacci

a guest Oct 23rd, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.codewithDZM;
  2.  
  3. import java.util.*;
  4.  
  5. public static int fibonacci (int n)
  6.         {
  7.             if (n<2)
  8.             {
  9.             return n;
  10.             }
  11.             else
  12.  
  13.             return  ( (fibonacci (n-1) ) + ( fibonacci (n-2) ) );
  14.         }
  15.  
  16.  
  17.  
  18. public class Main
  19. {
  20.  
  21.     public static void main(String[] args)
  22.     {
  23.         int x;
  24.         Scanner sc = new Scanner (System.in);
  25.  
  26.         System.out.println ( fibonacci (x) );
  27.     }
  28.  
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top