# Useful Math

Daniel Weibel
Created 4 Sep 2017
Last updated 8 Nov 2017

Some simple but useful math reminders and tricks.

# Divison Terminology

How are they called again? 🤔

# Sum of Integers 1 to N

Approach: pair and add up corresponding high and low elements (first + last, second-first + second-last, etc.).

## If N is even

Great, we can make $\frac{N}{2}$ pairs:

• $1 + N = N + 1$
• $2 + (N-1) = N + 1$
• $3 + (N-2) = N + 1$
• $4 + (N-3) = N + 1$
• $\ldots$

$\frac{N}{2}$ sums of value $N+1$:

## If N is odd

Prepend a 0 to make the number of summands even:

• $0 + N = N$
• $1 + (N-1) = N$
• $2 + (N-2) = N$
• $3 + (N-3) = N$
• $\ldots$

$\frac{N+1}{2}$ sums of value $N$:

## Conclusion

In all cases, the sum of integers 1 to $N$ is:

# Sum of Integers 1 to N-1

Analogous to the sum of integers 1 to $N$.

## If N is even (i.e. N-1 is odd)

• $0 + (N-1) = N - 1$
• $1 + (N-2) = N - 1$
• $2 + (N-3) = N - 1$
• $3 + (N-4) = N - 1$
• $\ldots$

$\frac{N}{2}$ sums of value $N-1$:

## If N is odd (i.e. N-1 is even)

• $1 + (N-1) = N$
• $2 + (N-2) = N$
• $3 + (N-3) = N$
• $4 + (N-4) = N$
• $\ldots$

$\frac{N-1}{2}$ sums of value $N$:

## Conclusion

In all cases, the sum of integers 1 to $N-1$ is:

# Sum of Powers of 2

What is the sum of the following?

## Example N = 4

The solution can be easily seen by taking an example and writing the terms in binary notation:

## Conclusion

The sum of the powers of 2 from 0 up to $N$ ($2^0 + 2^1 + \ldots + 2^N$), is:

# Floor and Ceiling

## Floor function

Go down to the nearest integer.

## Ceiling function

Go up to the nearest integer.