Computer Science, asked by sayanidassneha, 9 months ago

write a java program to print
1
31
531
7531
97531​

Answers

Answered by av1266108
1

Answer:

public static void main

Answered by kailashmeena123rm
15

ANSWER

import java.util.Scanner;

public class Pattern {

public static void main(String[] args)

Scanner scanner = new Scanner(System.in);

System.out.print("Enter n: ");

int n = scanner.nextInt();

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

int currentNum = 2 * i - 1;

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

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

currentNum = currentNum - 2;

}

System.out.println();

}

}

}

in this program you first enter value of row 5

to get desire output

Similar questions