BapBapuHa

triangleOfNumbers

May 25th, 2020
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int num = scanner.nextInt();
  9.         for (int i = 1; i <= num; i++) {
  10.             for (int j = 1; j <= i ; j++) {
  11.                 System.out.print(i + " ");
  12.                 if (j == i) {
  13.                     System.out.printf("%n");
  14.                 }
  15.             }
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment