You may choose to use either a for loop or a while loop on this problem.

Reasons to use a for loop include:

* it's a monotonic integer sequence
* it has a known starting and ending condition
* it may involve initialization of a range variable

Reasons to use a while loop include:

* the range variable may be initialized already
* the increment/update step may be merged with the ending condition

Consider the following:

Code:
    for (int denom = x-2; denom > 1; --denom)

    while (x-- > 1)
Depending on how you wrote the code leading up to the loop, either one of those loops might be the solution you want. It depends on your coding approach.

If you are designing your function around the loop, I would recommend you choose the for loop. It's a bit more clear and makes it obvious to both you and any teacher (or helper on the interwebs) what you intend to accomplish.