Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NumberPyramid {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int row = 0;
- int caunt = 0;
- while (true) {
- row++;
- for (int i = 1; i <= row; i++) {
- caunt++;
- System.out.print(caunt + " ");
- if (caunt == n) {
- return;
- }
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment