If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Numbered repetition of instructions

Problem

A visual artist is programming an 8x8 LED display:
8x8 grid of squares.
This is their program so far:
rowNum ←  0
REPEAT 5 TIMES
{
   colNum ← 0
   REPEAT (5 - rowNum) TIMES
   {
     fillPixel(rowNum, colNum, "red")
     colNum ← colNum + 1
    }
    rowNum ← rowNum + 1
}
The code relies on this procedure:
fillPixel(row, column, color) : Lights up the pixel at the given row and column with the given color (specified as a string). The top row is row 0 and the left-most column is column 0.
What will the output of their program look like?
Choose 1 answer:
🤔