1 + 2 + … + n

1 + 2 + … + n = n(n+1)/2. That is worth remembering; it comes up a lot in analysis of algorithms.

Obviously, n(n+1)/2 can be computed using only a few steps, so repetition is not really required to compute 1 + 2 + … + n. But for the purposes of these notes, computing 1 + 2 + … + n is a simple problem that serves to illustrate repetition.