Computer Science, asked by lavanyalavanya1853, 1 year ago

Write a java program to print a patter like
1
21
321
4321
54321

Answers

Answered by Anonymous
0

Answer:

please  mark branlist answer please please

Explanation:

import java.util.Scanner;

 

public class Pattern {

 

   public static void printPattern(int n) {

       for (int i = 1; i <= n; i++) {

           for (int j = i; j >= 1; j--) {

               System.out.print(j + " ");

           }

           System.out.println();

       }

   }

 

   public static void main(String[] args) {

       Scanner scanner = new Scanner(System.in);

       System.out.print("Enter a number: ");

       int n = scanner.nextInt();

       printPattern(n);

   }

 

}

Similar questions