2A. Let $a_{1}, a_{2}, \ldots$ be an arithmetic progression with difference $d$, and $b_{1}, b_{2}, \ldots$ be a geometric progression with ratio $q, q \neq 1$.

Calculate the sum

$$
S_{n}=a_{1} b_{1}+a_{2} b_{2}+\ldots .+a_{n} b_{n}
$$
Solution. Since for every natural number $k$ we have

$$
a_{k}=a_{1}+(k-1) d ; b_{k}=b_{1} q^{k-1}
$$

for $S_{n}$ we get:

$$
\begin{aligned}
S_{n} & =a_{1} b_{1}+a_{2} b_{2}+\ldots .+a_{n} b_{n} \\
& =a_{1} b_{1}\left(1+q+q^{2}+\ldots+q^{n-1}\right)+d b_{1} q\left(1+2 q+\ldots+(n-1) q^{n-2}\right) \\
& =a_{1} b_{1} \frac{1-q^{n}}{1-q}+d b_{1} q\left(1+2 q+\ldots+(n-1) q^{n-2}\right) \\
& =a_{1} b_{1} \frac{1-q^{n}}{1-q}+d b_{1} q \frac{(n-1) q^{n}-n q^{n-1}+1}{(1-q)^{2}}
\end{aligned}
$$

The sum

$$
1+2 q+\ldots+(n-1) q^{n-2}
$$

is calculated as follows:

$$
\begin{aligned}
1+2 q+\ldots+(n-1) q^{n-1} & =\left(1+q+q^{2}+\ldots+q^{n-1}\right)+\left(q+q^{2}+\ldots+q^{n-2}\right)+\ldots+\left(q^{n-3}+q^{n-2}\right)+q^{n-2} \\
& =\frac{1-q^{n-1}}{1-q}+q \frac{1-q^{n-2}}{1-q}+q^{2} \frac{1-q^{n-3}}{1-q}+\ldots+q^{n-3} \frac{1-q^{2}}{1-q}+q^{n-2} \\
& =\frac{1+q+q^{2}+\ldots+q^{n-2}-(n-1) q^{n-1}}{1-q} \\
& =\frac{\frac{1-q n-1}{1-q}-(n-1) q^{n-1}}{1-q}=\frac{(n-1) q^{n}-n q^{n-1}+1}{(1-q)^{2}}
\end{aligned}
$$