Back to Patterns
Butterfly Star Pattern
Pattern Result
* *** ***** ******* **************************** ******* ***** *** *
Code Implementation
Explanation
The Butterfly Pattern creates a shape that resembles a butterfly using asterisks. The pattern consists of two halves: the upper half where the wings 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.