Skip to the content.

pattern-printing-java

Note

  1. Number of lines = number of rows = number times the outer loop will run
  2. Identify for every row numbers, how many columns are there or types of elements in the column
  3. What do you need to print
  4. Try to find the formula relating rows and columns

Patterns Covered Here (Using Java)

Pattern 1

* 
* * 
* * * 
* * * * 

Source Code

Pattern 2

* * * * 
* * * * 
* * * * 
* * * * 

Source Code

Pattern 3

* * * * 
* * * 
* * 
* 

Source Code

Pattern 4

1 
1 2 
1 2 3 
1 2 3 4 

Source Code

Pattern 5

* 
* * 
* * * 
* * * * 
* * * * * 
* * * * 
* * * 
* * 
* 

Source Code

Pattern 6

    *
   * *
  * * *
 * * * *
* * * * *
 * * * *
  * * *
   * *
    *

Source Code

Pattern 7

        1 
      2 1 2 
    3 2 1 2 3 
  4 3 2 1 2 3 4 
5 4 3 2 1 2 3 4 5

Source Code

Pattern 8

        1 
      2 1 2 
    3 2 1 2 3 
  4 3 2 1 2 3 4 
5 4 3 2 1 2 3 4 5
  4 3 2 1 2 3 4
    3 2 1 2 3
      2 1 2
        1

Source Code

Pattern 9

4 4 4 4 4 4 4 4 4 
4 3 3 3 3 3 3 3 4 
4 3 2 2 2 2 2 3 4 
4 3 2 1 1 1 2 3 4 
4 3 2 1 0 1 2 3 4
4 3 2 1 1 1 2 3 4
4 3 2 2 2 2 2 3 4
4 3 3 3 3 3 3 3 4
4 4 4 4 4 4 4 4 4

Source Code