Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Task17_4 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int i = 2, f1 = 0, f2 = 1, cur = 0;
- int n = sc.nextInt();
- while (i <= n) {
- cur = f1 + f2;
- f1 = f2;
- f2 = cur;
- i++;
- }
- if (n <= 1)
- System.out.println(n);
- else System.out.println(cur);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment