forked from avinashbest/java-coding-ninjas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverseTriangle.java
More file actions
33 lines (30 loc) · 769 Bytes
/
ReverseTriangle.java
File metadata and controls
33 lines (30 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package pattern2;
import java.util.Scanner;
//for N = 4 print the pattern
// *
// * *
// * * *
// * * * *
public class ReverseTriangle {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int i = 1;
while (i <= n) {
int j = 1;
// Number of spaces to be printed n - i
while (j <= n - i) {
System.out.print("\t");
j++;
}
j = 1;
// Number of stars to be printed i
while (j <= i) {
System.out.print("*\t");
j++;
}
System.out.println();
i++;
}
}
}