Java program to print pascal’s number of rows

Java program to print pascal’s number of rows. Pascal number program in a java programming language. This program will print the pascal pattern in numbers in java. pascal program is an important method and pattern in every programming language

public class Main
{ 
public static void main(String[] args) 
{ 
int lines=5;
for (int i = 1; i <= lines; i++) 
{ 
for (int j = 1; j <= i; j++) 
{ 
System.out.print(j+" "); 
} 
System.out.println(); 
}
for (int i = lines-1; i >= 1; i--) 
{ 
for (int j = 1; j <= i; j++) 
{ 
System.out.print(j+" "); 
} 
System.out.println(); 
} 
} 
}

Output:

1                                                                                                                               

1 2                                                                                                                             

1 2 3                                                                                                                           

1 2 3 4                                                                                                                         

1 2 3 4 5                                                                                                                       

1 2 3 4                                                                                                                         

1 2 3                                                                                                                           

1 2                                                                                                                             

1