I want to find the coefficients of the $n$-th degree polynomial obtained from the expansion of the binomial product:
$$\prod_{i=1}^n{(x-a_i)}$$
where $x$ and $a_i$ are real numbers. Is there any efficient formula or recursive algorithm to calculate such coefficients? I found in wikipedia the formula for the more general case of the multi-binomial product but it does not seem very efficient.
This is a case covered by Vieta's formulae: $$ \prod_{i=1}^n (x-a_i) = \sum_{k=1}^n A_k x^k, $$ where $ A_n = 1 $, and the others are given by \begin{align} A_{n-1} &= -\sum_i a_i, \\ A_{n-2} &= + \sum_{i_1 < i_2} a_{i_1} a_{i_2}, \\ &\,\,\vdots \\ A_0 &= (-1)^n a_1 a_2 \cdots a_n, \end{align} where $A_k$ contains all possible products of $n-k$ distinct $a_i$s. This is the simplest possible way of writing these in general.