JAVA
java
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
/*
Create a program which will make a Pascal's triangle 1>Using Arrays 2>Without using Arrays
Version 2 not using an array
*/
import java.util.*;
public class BillPascal2{
public static void main(String[] args){
Scanner Scn = new Scanner(System.in);
int mn = Scn.nextInt() + 1;
if(mn>12){
System.out.println("The neatnest of the format fails after 12.");
}
for(int n=0; n<mn; n++){
System.out.format("%n");
for(int i=mn-n; i>0; i--){
System.out.format("%2s", "");
}
System.out.format("1");
int t = 1;
for(int i=1;i<=n;i++){
t = (t * (n+1-i))/i;
System.out.format(" %3d", t);
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run