Advertisement
knyazer

Untitled

Dec 1st, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. import static java.lang.Math.*;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8. Scanner sc = new Scanner(System.in);
  9.  
  10. int n = sc.nextInt();
  11. int[] a = new int[n + 2];
  12. a[0] = 1;
  13. a[1] = 1;
  14. for (int i = 2; i < n + 2; i++)
  15. a[i] = a[i - 1] + a[i - 2];
  16.  
  17. for (int i = 0; i < n; i++)
  18. System.out.printf("%d ", a[i]);
  19.  
  20. System.out.println("");
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement