For starter, recall that an arithmetic progression
is given recursively by

We can solve this explicitly for
in terms of
:



and so on, down to

More generally, we can express
in terms of an arbitrary term
:

(notice how the index of
and the coefficient of
on the right side add to
)
Let
be the
-th term of this particular progression. We're given

from which it follows that



If
, it follows that

Otherwise, if
, then

The sum of the first
terms of an arithmetic progression
is

If
, then

so that

Otherwise, if
, then

so that
