6. Arithmetic & Geometric Progressions
Progressions

A sequence of numbers that are derived based on some mathematical relationship between terms is called a mathematical series.
Series can be of different types, two of which we study here.

Arithmetic Progression, where each successive term is equal to the previous term plus a constant called a "common difference". Typically the first term is represented by the letter a, and the common difference by d.
So the series of n terms here is: \$a, a+d, a+2d, ..., a+(n-1)*d\$
The sum of the first n terms is: \$a+(a+d)+(a+2d)+...+(a+(n-1)*d)=n*a+d*(1+2+3+...+(n-1))=n*a+d*(n-1)*n/2=(n/2)*[2a+(n-1)*d]\$
Here, we use the fact that the sum of the first n consecutive natural numbers = \$n*(n+1)/2\$.
This can be proved easily using either mathematical induction or the method of finite differences both of which are currently out of scope of this tutorial.
e.g. the series \$1, 3, 5, 7, 9, ..., 31. 31=1+15*2\$, so \$1+3+...+31=16*(2+15*2)/2=256\$
Other useful math formulas:
The sum of the squares of the first n consecutive natural numbers = \$n*(n+1)*(2n+1)/6\$.
The sum of the cubes of the first n consecutive natural numbers=the square of the sum of the first n consecutive natural numbers=\$(n*(n+1)/2)^2\$

Geometric Progression, where each successive term is equal to the previous term times a constant called the "common ratio". Typically the first term is represented by the letter a, and the common ratio by r.
So the series of n terms here is: \$a, a*r, a*r*r, a*r*r*r, .... a*r^(n-1)\$.
The sum of the first n terms of this series is given by the formula \$S=a*(r^n-1)/(r-1)\$ if \$r>1\$ or \$a*(1-r^2)/(1-r)\$ if \$r<1\$.
e.g. \$1,2,4,8,16,...1024\$. So \$a=1, r=2, 1024=2^10\$, so \$n=11\$. \$S=1*(2^11-1)/(2-1)=2047\$