• 0

Print half pyramids using * as shown

Pattern 1 :

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

Logic :

iheightNumber of * (= i)
151
252
353
454
555

Solution :



Pattern 2 :

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

Logic :

iheightNumber of spaces (= height - i)Number of * (= i)
1541
2532
3523
4514
5505

Solution :



Pattern 3 :

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

Logic :

iheightNumber of * (= height - i + 1)
155
254
353
452
551

Solution :



Pattern 4 :

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

Logic :

iheightNumber of spaces (= i - 1)Number of * (= height - i + 1)
1505
2514
3523
4532
5541

Solution :