Write a program in Java to display the given pattern.
1
3 5
5 7 9
7 9 11 13
9 11 13 15 17
—————————————
• kindly don't give improper or spam answers
• best of luck! :)
Answers
Answered by
13
Question:-
Write a program in Java to display the following pattern.
1
3 5
5 7 9
7 9 11 13
9 11 13 15 17
Program:-
class Pattern
{
public static void main(String args[])
{
int rows=5, a, b=1;
for(int i=1;i<=rows;i++)
{
for(int j=1;j<=i;j++)
{
a=b;
System.out.print(a+" ");
a+=2;
}
b+=2;
System.out.println();
}
}
}
Answered by
5
Answer:
int a=1,b=1;
for (I=1;I<=5;I++)
{
for(j=1;j<=i;j++)
{
System.out.print(a);
a+=2;
}
b+=2;
a=b;
}
Similar questions