Advertisement
tchenkov

L07u13_NumberPyramid

Feb 21st, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. package Uprajneniq;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  * Created by todor on 21.02.2017 г..
  7.  */
  8. public class u13_NumberPyramid {
  9.     public static void main(String[] args) {
  10.         Scanner scan = new Scanner(System.in);
  11.         int endNumber = Integer.parseInt(scan.nextLine());
  12.         int i = 1;
  13.         int num = 1;
  14.         while (true){
  15.             for (int j = 0; j < i; j++) {
  16.                 System.out.printf("%d ", num);
  17.                 if (num == endNumber){
  18.                     return;
  19.                 }
  20.                 num++;
  21.             }
  22.             i++;
  23.             System.out.println();
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement