import java.util.Scanner;
public class Pattern {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter n: ");
int n = scanner.nextInt();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (j <= i) {
System.out.print(i + " ");
} else {
System.out.print(j + " ");
}
}
System.out.println();
}
}
Output:
12345
22345
33345
44445
55555
No comments:
Post a Comment