# Math.Pow and Array Values

Is there a way where I can get the total of the values in an array combined, but the array value is to the a power that is incremented by one for every increase in the array size. Also, if the array value is 0 the value will be skipped
example:

``````for (int Increment = 0; Increment < ArraySize; Increment++) {
if(TheArray[Increment] != 0) {
Math.Pow(TheArray[Increment], Increment);
}
}
``````

Edit: I have realized I have forgotten to mention this, but the number being multiplied by is suppose to be multiplied by 2.
The values in my array are dynamic, but say I have 5 values and they are

``````    0 -- 1 * 2
1 -- 0 * 2 (skipped (2 * 0 = 0)),
2 -- 1 * 2,
3 -- 0 * 2 (skipped (2 * 0 = 0)),
4 -- 1 * 2,
``````

What I want to happen is for the array row to be the power and the array’s value to be then powered by the power and then the values added together.

``````2 ^ 0 = 1,
2 ^ 2 = 4,
4 ^of 2 = 16,
----------------
1 + 4 + 16 = 21
``````

You original code is actually almost complete. All you need is a sum variable

``````double sum = 0;
for (int i= 0; i < TheArray.Length; i++) {
if(TheArray *!= 0) {*
``````

sum += Math.Pow(TheArray*, i);*
}
}
You shouldn’t use to complicated names for for-loop variables. Especially if they are used for different things. The variable is not an “increment” but just the index into the array.
May I ask what’s the actual point of this calculation? It seems a bit strange. I looks a little bit like a generic implementation of the tayler series. Though it would be wrong the way it’s handled.