PePetrov96

02. Pascal Triangle

Aug 31st, 2022
905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | Source Code | 0 0
  1. import java.util.Scanner;
  2. public class Test {
  3.     public static void main(String[] args) {
  4.         Scanner scan = new Scanner(System.in);
  5.         long n = Integer.parseInt(scan.nextLine());
  6.  
  7.         for (long line = 1; line <= n; line++) {
  8.             long C = 1;
  9.             for(long i = 1; i <= line; i++) {
  10.                 System.out.print(C + " ");
  11.                 C = C * (line - i) / i;
  12.             }
  13.             System.out.println();
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment