Skip to content

Instantly share code, notes, and snippets.

@bijay-shrestha
Created July 3, 2021 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bijay-shrestha/5643c9df0c157909392c0fd41b277fcf to your computer and use it in GitHub Desktop.
Save bijay-shrestha/5643c9df0c157909392c0fd41b277fcf to your computer and use it in GitHub Desktop.
/**
* * Print a numbered flag
* * 1
* * 12
* * 123
* * 1234
* * 12345
*/
package com.basic.practice;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class PrintNumberedFlag {
public static void main(String[] args) {
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j);
}
System.out.println("");
}
}
}
@sanjmgr
Copy link

sanjmgr commented Aug 16, 2022

public class PrintNumberedFlag {
    public static void main(String[] args) {
        int col = 5;

        for (int i = 0; i < col; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print(j + 1 + " ");
            }
            System.out.println("");
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment