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