Java – Right Pascal’s Triangle Patterns

Pattern:

 
*
**
***
****
*****
****
***
**
*

Code:

for(int i=1 ; i<10 ; i++)
{
            if(i<=5){
                        for(int j=1 ; j<=i ; j++){
                                    System.out.print(“*”);
                        }
                        System.out.println();
            }
            else{
                        for(int k=i ; k<10 ; k++){
                                    System.out.print(“*”);
                        }
                        System.out.println();
            }
}

Pattern:

*****
****
***
**
*
**
***
****
*****

Code:

for(int i=1 ; i<10 ; i++)
{
            if(i<=5){
                        for(int j=i ; j<=5 ; j++){
                                    System.out.print(“*”);
                        }
                        System.out.println();
            }
            else{
                        for(int k=5 ; k<=i ; k++){
                                    System.out.print(“*”);
                        }
                        System.out.println();
            }
}

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top