Skip to content

Commit 59da9cd

Browse files
authored
Add files via upload
1 parent c050653 commit 59da9cd

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Assignment-4/PascalTriangle.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* PROGRAM : To generate the Pascal traingle pattern
3+
* FILE : PascalTriangle.java
4+
* CREATED BY: Santosh Hembram
5+
* DATED : 14-09-20
6+
*/
7+
import java.util.*;
8+
class PascalTriangle {
9+
10+
public static void main(String[] args) {
11+
12+
Scanner sc = new Scanner(System.in);
13+
System.out.print("Enter the number of rows: ");
14+
int row = sc.nextInt();
15+
16+
int space = row;
17+
int number = 1;
18+
19+
for (int i=0; i<row; i++ ) {
20+
21+
for (int s=1; s<=space; s++ ) {
22+
System.out.print(" ");
23+
24+
}
25+
number = 1;
26+
for (int j=0; j<=i; j++ ) {
27+
System.out.print(number+" ");
28+
number = number * (i-j)/(j+1);
29+
30+
}
31+
space--;
32+
System.out.println();
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy