logoStarPatterns
Back to Patterns

Alphabet V Pattern

Pattern Result

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

Code Implementation

Explanation

The Alphabet V Pattern creates a shape that resembles the letter V using asterisks. The pattern places stars at specific positions to create the slanted sides of the V. As the row number increases, the distance between the two stars decreases, creating the V shape. The algorithm ensures that n is odd to create a symmetrical V. The outer loop iterates through each row, and the inner loops handle the spaces before the first star, the first star, the spaces between the stars, the second star (if not the last row), and the spaces after the second star. In the last row, only one star is placed in the middle to form the bottom of the V.