I have an array `y` of dimension `n`, every dimension has `m` entries.
How do I iterate over all combinations of indices using nested `for` loops?

I'd like to get all possible combinations of sums like shown in this code:

```
for (int i = 0; i < m; ++i) {

    for (int j = 0; j < m; ++j) {
        ...
        for (int k = 0; k < m; ++k) {
            z = x[0] + y[i]*x[1] + y[j]*x[2] + ... + y[k]*x[n];
        }
    }
}

```

If this is not possible using `for` loops, how else can it be achieved?