We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bd752b3 commit be30772Copy full SHA for be30772
Pattern-2/Mirror_Image_Number_Pattern.java
@@ -0,0 +1,35 @@
1
+/*
2
+Print the following pattern for the given N number of rows.
3
+Pattern for N = 4
4
+
5
+ 1
6
+ 1 2
7
+ 1 2 3
8
+1 2 3 4
9
+*/
10
11
+import java.util.*;
12
13
+public class Mirror_Image_Number_Pattern {
14
+ public static void main(String[] args) {
15
16
+ /*
17
+ * Your class should be named Solution.
18
+ * Read input as specified in the question.
19
+ * Print output as specified in the question.
20
+ */
21
+ Scanner sc = new Scanner(System.in);
22
+ int n = sc.nextInt();
23
+ int count = 1;
24
+ for (int i = n; i > 0; i--) {
25
+ for (int j = 1; j < i; j++)
26
+ System.out.print(" ");
27
+ for (int j = 1; j <= count; j++) {
28
+ System.out.print(j);
29
+ }
30
+ System.out.println();
31
+ count++;
32
33
34
35
+}
0 commit comments