

The variable $n$ played a slightly different role here. In the first case it was the upper limit, and in this case it is was the number of terms, while $x$ takes on the values 0 through $n1$.

We can conclude that this defines an arithmetic progression of the form
$\alpha + \beta \,x$
with $\alpha$ = ap[0] and $\beta$ = d1[0] = d1[1] = ....
This is the exact discrete counterpart to solving the first order differential equation
$\frac{d}{dt}x(t) = \beta$, $x(0) = \alpha$
where $\beta$ is a constant.


By analogy with the second order differential equation
$\frac{d^2}{dt^2}x(t) = \gamma$ $x(0) = \alpha$ $\frac{d}{dt}x(0) = \beta$
with $\alpha$ = s1[0], $\beta$ = d1[0], and $\gamma$ a constant.
To get the solution to the differential equation we integrate twice. The first integration gives us
$\frac{d}{dt}x(t) = \gamma x + \beta$
and the second integration gives us
$x(t) = \frac{1}{2} \gamma x^2 + \beta x + \alpha$
So, is there a similar formula in $n$ for the discrete case? If so, should it be of the form
$a n^2 + b n + c$ ?
First, paste the sequence into the Online Encyclopedia of Integer Sequences
http://www.research.att.com/~njas/sequences/
For $\alpha =5$ and $\beta=2$ this is sequence A028347, which has the formula $n^2  4$ with an offset of 2. That is, $(n+2)^24$ for the sequence as displayed.
Since our sequence starts with the second term of A028347 our formula is $(n+3)^2  4 = n^2 + 6n + 5$
We also see that this sequence also occurs in a number of other situations including the Balmer series of the Hydrogen atom, and there is even a Sage formula for generating the sequence based on the Lucas numbers.

Second, recall that you probably saw this problem a long time ago as
$S_n = \alpha + (\alpha + \beta) + (\alpha + 2\beta) + \cdots + (\alpha + n\beta) = \sum_{k=0}^{n} \alpha + k \beta$
which has a nice geometric interpretation as a staircase that covers half the rectangle of height $2 \alpha + n \beta$ and width $n+1$.

In other words
$S_n = \frac{1}{2}(2\alpha + n \beta) (n+1)) = \frac{1}{2}(\alpha + [\alpha+n \beta]) (n+1)$
or "one half of the first plus the last times the number of terms". For the case $\alpha = 5$ and $\beta = 2$ we get
$S_n = \frac{5 + (5 + n 2)}{2}(n+1) = (5+n)(n+1) = n^2 + 6n + 5$
Third, you can assume that the sum is a quadratic polynomial of the form
$S_n = a n^2 + b n + c$
and solve for the coefficients using three different values of ($n$, $S_n$).


The next step would then be to show that the resulting formula works for all values of $n$. This provides an excellent opportunity to use mathematical induction.
Base step: $S_0 = \frac{1}{2}(2\alpha + 0 \beta) (0+1)) = \alpha $
Inductive step:
$S_{n+1} = S_n + \alpha + (n+1) \beta = \frac{1}{2}(\alpha + [\alpha + n \beta]) (n+1) + \alpha + (n+1) \beta = \frac{1}{2}\left( (\alpha + [\alpha + n \beta]) (n+1) + 2\alpha + 2(n+1) \beta \right)$
$S_{n+1} = \frac{1}{2} \left( \alpha(n+2) + \alpha(n+2)+(n+2)\beta(n+1) \right) = \frac{1}{2} (\alpha + [\alpha+(n+1)\beta])(n+2) $
Let's now explore binomial expansions, Pascal's triangle, and more interesting sequences of sums.



If we sum the first $N$ elements in column $k$ that sum will be the value of the element in the next row and column, namely, row $N+1$ and column $k+1$.
$\sum\limits_{n=k}^N P_{n,k} = P_{N+1,k+1}$
Since $P_{n,k} = \left( {\begin{array}{*{20}c} n \\ k \\ \end{array}} \right)$ this is the same as the statement
$\sum\limits_{n=k}^N \left( {\begin{array}{*{20}c} n \\ k \\ \end{array}} \right) = \left( {\begin{array}{*{20}c} N+1 \\ k+1 \\ \end{array}} \right)$
or, if we use the factorial definition of $n$ choose $k$
$\sum\limits_{n=k}^N \frac{n!}{(nk)! k!} = \frac{(N+1)!}{(Nk)!(k+1)!}$
Actually, this observation holds for all cases, and the Theorem is easy to prove by mathematical induction.
Look at each row of Pascal's Triangle. In all the cases in the Table, if $n$ is a prime (2, 3, 5, 7, 11), then $n$ divides all the entries in the row between the first and last, which are ones. On the other hand, when $n$ is not a prime (4, 6, 8, 9, 10), then $n$ does not divide every entry in the row. In particular, 4 doesn't divide 6; 6 doesn't divide 15 or 20; 8 doesn't divide 28; 9 doesn't divide 84; 10 doesn't divide 45; and 12 doesn't divide 66.
This observation also holds for all cases, and the result along with Eisenstein's criterion can be used to show that polynomials of the form
$x^{p1} + x^{p2} + \cdots + x + 1$
cannot be factored over the rational numbers when $p$ is a prime.
























