## Lesson goal: A series that diverges

Previous: What kinds of numbers? | Home | Next: Numbers ending in 1

Here's a lesson that uses the for-loop to study a series (a series is a bunch of numbers added together). In pre-calculus or calculus, you might have learned that $\Sigma\frac{1}{n}$ diverges (or gives an infinite value if you run the sum over an infinite number of terms). If you take the first few terms in the sum, you'll get $1+\frac{1}{2}+\frac{1}{3}+\frac{1}{4}+...$. Each term gets smaller and smaller, so does it really diverge? Let's write some code here to test it.

As you work on this, notice the similarities between the $\Sigma$ from math, and the for-loop in programming. In this case $\Sigma_{n=a}^{b}$ runs $n$ from $a$ to $b$, while for n=a,b do runs n from a to b.