# How to automatically sum the squares, cubes, etc, of a list of integers?

1. ## How to automatically sum the squares, cubes, etc, of a list of integers?

Hello.

I have a lot of lists of integers and I want to sum their Xth power automatically, for X = -3, -2, -1, -1/2, 0, 1/2, 1, 2, 3, 4, 5, 6.

For example, take this short list of integers: 1 2 3 4 6 12

The sum of their Xth power must be: 1^X + 2^X + 3^X + 4^X + 6^X + 12^X

How can I do that?

2. ## Re: How to automatically sum the squares, cubes, etc, of a list of integers?

Hi,

With your values in e.g. A1:A10 and your index in e.g. B1:

=SUMPRODUCT(POWER(A1:A10,B1))

Regards

3. ## Re: How to automatically sum the squares, cubes, etc, of a list of integers?

Thank you XOR LX, your function worked.

There is just one last little problem: the function doesn't work for X = 0

Basically for X = 0 we should get:
1^0 + 2^0 + 3^0 + 4^0 + 6^0 + 12^0
= 1 + 1 + 1 + 1 + 1 + 1
= 6
It should just give us the quantity of integers present in the list..

4. ## Re: How to automatically sum the squares, cubes, etc, of a list of integers?

You mean you've included some blank cells in the range as well?

Regards

5. ## Re: How to automatically sum the squares, cubes, etc, of a list of integers?

Oh yes, you're correct. Oops.

Just fixed it, everything is perfect now.

Thanks again for everything.

6. ## Re: How to automatically sum the squares, cubes, etc, of a list of integers?

You're welcome.

Actually if your set-up is such that your range may include blanks, you can use this array formula**:

=SUM(IFERROR(POWER(A1:A10,B1),0))

Regards

**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

There are currently 1 users browsing this thread. (0 members and 1 guests)