chillurbrain

Task16Lab4_2

Dec 8th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.35 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Task17_4 {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         int i = 2, f1 = 0, f2 = 1, cur = 0;
  7.         int n = sc.nextInt();
  8.         while (i <= n) {
  9.             cur = f1 + f2;
  10.             f1 = f2;
  11.             f2 = cur;
  12.             i++;
  13.         }
  14.         if (n <= 1)
  15.             System.out.println(n);
  16.         else System.out.println(cur);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment