- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram15_PatternB.java
More file actions
Latest commit
29 lines (27 loc) · 795 Bytes
/
Copy pathProgram15_PatternB.java
File metadata and controls
29 lines (27 loc) · 795 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
/*
Write a Java program to make such a pattern like a right angle triangle with the number increased by 1.
The pattern like :
1
2 3
4 5 6
7 8 9 10
*/
// Date : 28/12/2023, Author : Yash Wadhvani
importjava.util.Scanner;
publicclassProgram15_PatternB {
publicstaticvoidmain(String[] args) {
try (Scannersc = newScanner(System.in)) {
System.out.println("Enter No. of Rows for Triangle :-");
intn = sc.nextInt();
intsum = 1;
System.out.print("\n");
for (inti = 1; i <= n; i++) {
for (intj = 1; j <= i; j++) {
System.out.print(sum + " ");
sum++;
}
System.out.print("\n");
}
}
}
}