If the outer loop runs from 1 to N, the number of stars per row is N - row + 1.
How to Print an Inverted Right-Angled Triangle Pattern
What is the formula for an inverted right-angled triangle?
The answer
More FAQs in How to Print an Inverted Right-Angled Triangle Pattern
Reversing the outer loop (starting from N and decrementing) is usually much cleaner and easier to read, reducing the chance of off-by-one math errors.
Use the same loop structure, but inside the inner loop, print the variable 'col' (for 1234, 123) or 'row' (for 4444, 333).
You likely used <= instead of < when checking the boundary, causing the math to yield 0 on the final iteration, or you started counting from 0 instead of 1 without adjusting the math.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.