SHARE
TWEET

Untitled

a guest Jul 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class RecursiveFibonacci {
  4.     public static void main(String[] args) {
  5.         Scanner scanner=new Scanner(System.in);
  6.  
  7.         int n=Integer.parseInt(scanner.nextLine());
  8.  
  9.         int[]numbers=new int[n];
  10.         int []masiv=new int[numbers.length];
  11.  
  12.         //for (int i = 0; i <n ; i++) {
  13.         if (n>=1 && n<=50) {
  14.             numbers[0] = 1;
  15.             numbers[1] = 1;
  16.             for (int j = numbers[1] + 1; j < numbers.length; j++) {
  17.                 numbers[j] = numbers[j - 1] + numbers[j - 2];
  18.             }
  19.         }
  20.  
  21.        // }
  22.         System.out.println(numbers[numbers.length-1]);
  23.     }
  24. }
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