Find the coefficients of the polynomial given its roots
问题 I am trying to write an algorithm which will find a(0),..., a(n-1) , given the values of n, x_1, ..., x_n, a(n) , such that: a(n)*p^n + a(n-1)*p^(n-1) + ... + a(1)*p + a(0) = a(n)(p-x_1)(p-x_2)...(p-x_n) for all real p. After multiplying a(n)(p-x_1)(p-x_2) I've thought of using Viete's formulas to find the coefficients. But it turns out writing the code down isn't as obvious as I expected. I want to use only the basics in my code - that is loops, if-s addition and multiplication - no ready/