> For the complete documentation index, see [llms.txt](https://liuzhenglaichn.gitbook.io/algorithm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liuzhenglaichn.gitbook.io/algorithm/math/sum-of-sequence.md).

# Sum Of Sequence

The series $\sum\limits\_{k=1}^n k^a = 1^a + 2^a + 3^a + \dots + n^a$ gives the sum of the $a^\text{th}$ powers of the first nn positive numbers, where aa and $n$ are positive integers. Each of these series can be calculated through a closed-form formula.

The case $a=1,n=100$ is famously said to have been solved by Gauss as a young schoolboy: given the tedious task of adding the first 100 positive integers, Gauss quickly used a formula to calculate the sum of 5050.

The formulas for the first few values of $a$ are as follows:

$$\sum\limits\_{k=1}^n k = \frac{n(n+1)}{2}$$

$$\sum\limits\_{k=1}^n k^2 = \frac{n(n+1)(2n+1)}{6}$$

$$\sum\limits\_{k=1}^n k^3 = \frac{n^2(n+1)^2}{4}$$

## Reference

* <https://brilliant.org/wiki/sum-of-n-n2-or-n3/>
