The challenge is to write a program that takes the coefficients of any n-degree polynomial equation as input and returns the integral values of x for which the equation holds true. The coefficients will be provided as input in the order of decreasing or increasing power. You can assume all the coefficients to be integers.
Input And Output
The input will be the coefficients of the equation in decreasing or increasing order of power. The degree of the equation, i.e, maximum power of x, is always 1 less than the total no of elements in the input.
[1,2,3,4,5] -> represents x^4 + 2x^3 + 3x^2 + 4x + 5 = 0 (degree = 4, as there are 5 elements) [4,0,0,3] -> represents 4x^3 + 3 = 0 (degree = 3, as there are 3+1 = 4 elements)
Your output should be only the distinct integral values of x which satisfy the given equation. All the input coefficients are integers and the input polynomial will not be a zero polynomial. If there is no solution for the given equation, then the output is undefined.
If an equation has repeated roots, display that particular root only once. You can output the values in any order. Also, assume that the input will contain at-least 2 numbers.
[1,5,6] -> (-3,-2) [10,-42,8] -> (4) [1,-2,0] -> (0,2) [1, 1, -39, -121, -10, 168] -> (-4, -3, -2, 1, 7) [1, 0, -13, 0, 36] -> (-3, -2, 2, 3) [1,-5] -> (5) [1,2,3] -> -
Note that the equation in the second example also has the root 0.2, but it is not displayed as 0.2 is not an integer.
This is code-golf, so the shortest code (in bytes) wins!