logoStarPatterns
Back to Patterns

Double Pyramid Pattern

Pattern Result

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

Code Implementation

Explanation

The Double Pyramid Pattern creates a shape that resembles two pyramids side by side, forming a pattern similar to a butterfly. The pattern consists of two halves: the upper half where the pyramids grow, and the lower half where they shrink. In each row of the upper half, the number of stars on each side increases while the number of spaces in the middle decreases. In the lower half, the pattern is reversed. The algorithm uses nested loops to create the pattern: the outer loops handle the upper and lower halves, while the inner loops handle the stars and spaces in each row.