write a java program to print
1
31
531
7531
97531
Answers
Answered by
1
Answer:
public static void main
Answered by
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
Math,
4 months ago
Computer Science,
4 months ago
Math,
4 months ago
Social Sciences,
9 months ago
Science,
11 months ago
English,
11 months ago