Computer Science, asked by sagarikaash1, 10 months ago


Write a program to display the given pattern:
3
5 6
8 9 10
12 13 14 15

Answers

Answered by anindyaadhikari13
4

Question:-

➡ Write a program in Java to display the following pattern.

3

5 6

8 9 10

12 13 14 15

Program:-

This is the shortest approach.

class Main

{

public static void main(String s[])

{

int a=3;

for(int i=1;i<=4;i++)

{

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

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

a++;

System.out.println();

}

}

}

For verification, check out the attachment.

Attachments:
Similar questions