Computer Applications
Write a program in Java to display the following pattern:
1
3 5
7 9 11
13 15 17 19
21 23 25 27 29
Java
Java Nested for Loops
17 Likes
Answer
public class KboatPattern
{
public static void main(String args[]) {
int term = 1;
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(term + " ");
term += 2;
}
System.out.println();
}
}
}
Output

Answered By
6 Likes
Related Questions
Write a program in Java to display the following pattern:
AAAAA
BBBB
CCC
DD
EWrite a program in Java to display the following pattern:
1
3 1
5 3 1
7 5 3 1
9 7 5 3 1Write a program in Java to input the values of x and n and print the sum of the following series:
S = 1 - x2/2! + x4/4! - x6/6! + ……. xn/n!
Write a program in Java to display the following pattern:
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1