While loops and for loops: Correct Solution


Part 1

Translate the following natural language description of a loop into a for loop:

Declare a variable named tre of type int, initialized to 29. Then, until tre is greater than or equal to gli, divide tre by 3.

Solution

for (int tre = 29; tre > gli; tre /= 3) {
    ...
}

Something to double-check in your solution:


Related puzzles: