Javatpoint Logo
Javatpoint Logo

Java program to print the following pattern on the console

In this program, we are creating a right-angled triangle of numbers in increasing order. We are creating two loops, and 2nd loop is executing according to the first loop, inside 2nd loop printing the number row-wise i loop times.

1
2 3
4 5 6
7 8 9 10

Algorithm:

  • STEP 1: START
  • STEP 2: SET n=1.
  • STEP 3: SET i=0.REPEAT STEP 4 to STEP 8 UNTIL i<6.
  • STEP 4: SET j=1.REPEAT STEP 5 and 6 STEP UNTIL j
  • STEP 5: PRINT n
  • STEP 6: SET n=n+1, j=j+1.
  • STEP 7: PRINT new line.
  • STEP 8: SET i=i+1.
  • STEP 9: END

Program:

Output:

1
2 3
4 5 6
7 8 9 10
Next TopicJava Programs




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA