Computer Science, asked by alex411, 5 months ago

how to print this this pattern
1
3 1
5 3 1
7 5 3 1
9 7 5 3 1​

Answers

Answered by Oreki
1

public class Pattern {

public static void main(String[ ] args) {

for (int i = 0; i < 5; i++) {

for (int j = 0; j < i + 1; j++)

System.out.print((1 + i * 2 - j * 2) + " ");

System.out.println( );

}

}

}

Answered by anindyaadhikari13
3

Question:-

Write a program to display the pattern.

1

3 1

5 3 1

7 5 3 1

9 7 5 3 1

Code:-

class Pattern

{

public static void main(String s[])

{

for(int i=1;i<=9;i+=2)

{

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

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

System.out.println();

}

}// end of main

}// end of class.

Similar questions