Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

Print half pyramids using * as shown

Pattern 1 :

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

Logic :

i height Number of * (= i)
1 5 1
2 5 2
3 5 3
4 5 4
5 5 5

Solution :


Pattern 2 :

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

Logic :

i height Number of spaces (= height – i) Number of * (= i)
1 5 4 1
2 5 3 2
3 5 2 3
4 5 1 4
5 5 0 5

Solution :


Pattern 3 :

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

Logic :

i height Number of * (= height – i + 1)
1 5 5
2 5 4
3 5 3
4 5 2
5 5 1

Solution :


Pattern 4 :

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

Logic :

i height Number of spaces (= i – 1) Number of * (= height – i + 1)
1 5 0 5
2 5 1 4
3 5 2 3
4 5 3 2
5 5 4 1

Solution :

You may also like...

2 Responses

  1. Fareez Ahmed says:

    what about pascal’s triangle?

Leave a Reply

Your email address will not be published. Required fields are marked *