Оценить многочлен

<script>
// Javascript program for implementation 
// of Horner Method for Polynomial
// Evaluation.

// returns value of poly[0]x(n-1) + 
// poly[1]x(n-2) + .. + poly[n-1]
function horner(poly, n, x)
{

    // Initialize result
    let result = poly[0]; 

    // Evaluate value of polynomial
    // using Horner's method
    for (let i = 1; i < n; i++)
        result = result * 
                  x + poly[i];

    return result;
}

// Driver Code

// Let us evaluate value of
// 2x3 - 6x2 + 2x - 1 for x = 3
let poly = new Array(2, -6, 2, -1);
let x = 3;
let n = poly.length

document.write("Value of polynomial is " +
         horner(poly, n, x));

// This code is contributed by _saurabh_jaiswal.
</script>
Poised Pelican