pascal triangle java
previous NextExample
import java.util.Scanner;
class PascalTriangle{
public static int fact(int num)
{
int f = 1, i=1;
while(i<=num)
{
f= f*i;
i++;
}
return f;
}
public static void main(String[] args) {
int line;
int i,j;
Scanner sc = new Scanner(System.in);
System.out.print("enter the no. of lines ");
line = sc.nextInt();
for (i=0; i
Output :
enter the no. of lines 5
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1