Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import static java.lang.Math.*;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- int[] a = new int[n + 2];
- a[0] = 1;
- a[1] = 1;
- for (int i = 2; i < n + 2; i++)
- a[i] = a[i - 1] + a[i - 2];
- for (int i = 0; i < n; i++)
- System.out.printf("%d ", a[i]);
- System.out.println("");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement