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