Math Fundamentals18 sections · 814 units
Open in Course

Common Algebraic Patterns in CP

Formulas you'll see often

Here are algebraic formulas you'll encounter repeatedly in competitive programming:

∙\bullet Sum of first nn integers: 1+2+...+n=n(n+1)21 + 2 + ... + n = \frac{n(n+1)}{2}

∙\bullet Sum of first nn squares: 12+22+...+n2=n(n+1)(2n+1)61^2 + 2^2 + ... + n^2 = \frac{n(n+1)(2n+1)}{6}

∙\bullet Geometric series: 1+r+r2+...+rn−1=rn−1r−11 + r + r^2 + ... + r^{n-1} = \frac{r^n - 1}{r - 1} for r≠1r \neq 1

∙\bullet Number of pairs: (n2)=n(n−1)2\binom{n}{2} = \frac{n(n-1)}{2}