-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern-3.java
More file actions
30 lines (20 loc) · 748 Bytes
/
pattern-3.java
File metadata and controls
30 lines (20 loc) · 748 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
// Pattern13- Pascal's Triangle Pattern
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
for(int i=0; i<n; i++){
// representing Binomial Coefficient C(i, j)
int iCj = 1;
for(int j=0; j<=i; j++){
//printing number pattern
System.out.print(iCj + "\t");
// calculating C(i, j+1) to be printed in next iteration
iCj = iCj * (i-j) / (j+1);
}
// printing new line
System.out.println();
}
}
}