The answer
Then it is likely a composite pattern (like a butterfly or a diamond) that requires breaking the shape into two separate linear halves.
Then it is likely a composite pattern (like a butterfly or a diamond) that requires breaking the shape into two separate linear halves.
Map the row number (X) to the star count (Y). Find the difference between Y values (the slope), and use basic algebra (y = mx + b) to find the formula.
The formula is (2 * row) - 1, assuming your row counter starts at 1.
The formula is exactly 2 * row, which prints 2, 4, 6, 8 stars progressively.
Browse all our FAQs or reach out to our support team
Your learning library
Find your next course. Build something great.
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success