pattern 6


We can print the following Pattern 
1) 
5 5 5 5 5         //print i
4 4 4 4 
3 3 3 
2 2 
1

2)
5 4 3 2 1          //print j
4 3 2 1 
3 2 1 
2 1 
1  

package demo;

import java.util.Scanner;

public class Pattern7 {
 public static void main(String[] args) 
    {
        Scanner sc = new Scanner(System.in);
         
        //Taking rows value from the user
         
        System.out.println("How many rows you want in this pattern?");
         
        int rows = sc.nextInt();
         
        System.out.println("Here is your pattern....!!!");
         
        for (int i = rows; i >= 1; i--) 
        {
            for (int j = i; j >= 1; j--)
            {
               // System.out.print(j+" ");
                System.out.print(i+" ");
            }
             
            System.out.println();
        }
         
        //Closing the resources
         
        sc.close();
    }
}

O/P:-
5
Here is your pattern....!!!
5 4 3 2 1 
4 3 2 1 
3 2 1 
2 1 
1