Skip to content

Commit 15d0c68

Browse files
committed
Pattern Problem
1 parent dec7fdd commit 15d0c68

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.java.patterns;
2+
3+
import java.util.Scanner;
4+
5+
/*
6+
* Write a Java Program to print the following Pattern
7+
1
8+
2 1
9+
3 2 1
10+
4 3 2 1
11+
5 4 3 2 1
12+
6 5 4 3 2 1
13+
*/
14+
public class Pattern8 {
15+
public static void main(String[] args) {
16+
Scanner scanner = new Scanner(System.in);
17+
System.out.println("Enter the number of rows to print the pattern :: ");
18+
int N = Integer.parseInt(scanner.nextLine().trim());
19+
20+
for(int i=1;i<=N;i++){
21+
for(int j=i;j>=1;j--)
22+
System.out.print(j+" ");
23+
System.out.println();
24+
}
25+
26+
scanner.close();
27+
}
28+
}
29+
/*
30+
OUTPUT
31+
32+
Enter the number of rows to print the pattern :: 10
33+
1
34+
2 1
35+
3 2 1
36+
4 3 2 1
37+
5 4 3 2 1
38+
6 5 4 3 2 1
39+
7 6 5 4 3 2 1
40+
8 7 6 5 4 3 2 1
41+
9 8 7 6 5 4 3 2 1
42+
10 9 8 7 6 5 4 3 2 1
43+
*/

0 commit comments

Comments
 (0)