Arithmetic Sequence: nth Term and Sum

From the first term and the common difference, finds the nth term a + (n−1)d of an arithmetic sequence and the sum of the first n terms.

In an arithmetic sequence, every term sits a fixed distance from the one before it. That distance is the common difference. Given the first term, the difference and a term number, you can get both the nth term and the running total up to it.

an=a+(n1)da_n = a + (n-1)d
Sn=n(a+an)2S_n = \dfrac{n(a + a_n)}{2}

Note the n1n - 1. Reaching the nth term takes n1n - 1 steps, not nn, because you start out already standing on the first term. That off-by-one is the classic trap.

Example

Start with a=3a = 3, d=4d = 4 and n=10n = 10. The sequence runs 3, 7, 11, 15, and so on.

a10=3+(101)×4=3+36=39a_{10} = 3 + (10 - 1) \times 4 = 3 + 36 = 39
S10=10×(3+39)2=4202=210S_{10} = \dfrac{10 \times (3 + 39)}{2} = \dfrac{420}{2} = 210

The tenth term is 39, and the first ten terms add to 210.

Notes