I got to learn the way for calculating coefficients of different powers of x in the product $(x+a_1)\cdot(x+a_2)\cdot(x+a_3)\cdot(x+a_4)\dots(x+a_n)$.It is as follows:
$$x^n+\left(\sum_{i=1}^{n}a_i\right)\cdot x^{n-1}+\left(\sum_{i=1}^{n}\sum_{j=i+1}^{n}a_i\cdot a_j\right)\cdot x^{n-2}+\cdots\cdots+\left(a_1\cdot a_2\cdot a_3\cdots a_n\right)$$
Is there any way to prove this?
When you try to multiply out $(x+a_1)(x+a_2)\dotsm(x+a_n)$, you will realise that inside each bracket $(x+a_k)$, you will need to "choose" one of them to be multiplied with the other terms, so to speak. For instance in the small case $n=2$, $$(x+a_1)(x+a_2)=(x\cdot x)+ (a_1\cdot x) + (x\cdot a_2)+(a_1\cdot a_2).$$ Each term comes from choosing one of the terms in the first bracket, another in the second bracket, and multiplying them, leading to four terms. Now, the coefficient of $x^k$ in the expansion of $(x+a_1)(x+a_2)\dotsm(x+a_n)$ must come from those terms which "chose" $x$ exactly $k$ times, so the remainder of the $n-k$ choices that were made must have been of the $a_i$. In fact, any such choice works. Hence, the coefficient of $x^k$ is $$\sum_{\mathrm{sym}}a_1a_2\dotsm a_{n-k}$$ where the $\mathrm{sym}$ indicates that we sum over all possible products of $n-k$ such $a_i$. This is strongly related to the concept of elementary symmetric polynomials, which I highly recommend you read more about.
For example, when $n=3$, we have $$\begin{split}(x+a_1)(x+a_2)(x+a_3)=&(x\cdot x\cdot x)+(x\cdot x\cdot a_3)+(x\cdot a_2\cdot x)+(x\cdot a_2\cdot a_3)\\ &+(a_1\cdot x\cdot x)+(a_1\cdot x\cdot a_3)+(a_1\cdot a_2\cdot x)+(a_1\cdot a_2\cdot a_3).\end{split}$$ Note that each term in this sum is the product of three factors. The first factor is a choice between $x$ and $a_1$, the second factor a choice between $x$ and $a_2$, and the third factor is a choice between $x$ and $a_3$. In order to look at, say, the coefficient of $x^2$, we will have to look at those terms with exactly two "$x$"s as factors. Since there are exactly $3$ factors in each term, and two factors are $x$s in our case, then the last factor must be either $a_1,a_2$ or $a_3$. Indeed all three work and appear in the sum, as you can check. So once we group the terms together, and bring out the $x^2$, we are left with the coefficient of $a_1+a_2+a_3$.