Skip to content

Commit aab3e9f

Browse files
committed
Pattern 38 - Techgig
1 parent b42279f commit aab3e9f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.java.patterns;
2+
import java.util.Scanner;
3+
/*
4+
Write the program to print the following pattern
5+
5 4 3 2 1
6+
5 4 3 2
7+
5 4 3
8+
5 4
9+
5
10+
*/
11+
public class Pattern38 {
12+
public static void main(String args[] ) throws Exception {
13+
Scanner scanner = new Scanner(System.in);
14+
int N = Integer.parseInt(scanner.nextLine());
15+
for(int i=0;i<N;i++){
16+
for(int j=N;j>i;j--)
17+
if(j == N)
18+
System.out.print(j);
19+
else
20+
System.out.print(" "+j);
21+
if(i != N-1)
22+
System.out.println();
23+
}
24+
scanner.close();
25+
}
26+
}
27+
/*
28+
Input
29+
5
30+
Output
31+
5 4 3 2 1
32+
5 4 3 2
33+
5 4 3
34+
5 4
35+
5
36+
*/

0 commit comments

Comments
 (0)