We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b42279f commit aab3e9fCopy full SHA for aab3e9f
InterviewPrograms/src/com/java/patterns/Pattern38.java
@@ -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
30
+Output
31
32
33
34
35
36
0 commit comments