# Exercise: Sum up integer powers¶

Task: Write a code to compute the value of $$\sum_{n=1}^N n^i$$ for any integers $i$ and $N$. (Solution codes will be ranked in terms of correctness, readability, and brevity.)

How do you know your answer is correct? When writing code it is important to check for correctness. Llementary mathematics tells us that $$\sum_{n=1}^N n^2 = \frac N 6 (N+1) (2N +1).$$ (If you don't know this prove it!) So you can easily check that your code gives the correct answer, at least for $i=2$. In fact, even for a general power $i$, power sums have been studied very well and expressions connecting them to the Riemann zeta function are well known, so for this task, there are indeed many sources to double check our code results.

Python has many styling guidelines for writing good code. You may want to peruse PEP 8 at your leisure. And take time to behold an easter egg (one of several) within the language:

In :
import this

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.