/**
 * This function takes an input value 'x' and a list of coefficients and calculates the value of the polynomial
 * for the given value of 'x'. The coefficients are ordered from highest degree to lowest degree.
 */
fun evaluatePolynomial(x: Double, coefficients: List<Double>): Double {

    val degree = coefficients.size - 1
    var result = 0.0
    var i = degree

    while (i >= 0) {
        result += coefficients[i] * Math.pow(x, (degree - i).toDouble())
        i--
    }

    return result
}
/**
 * This function takes an input value 'x' and a list of coefficients and calculates the value of the polynomial
 * for the given value of 'x'. The coefficients are ordered from highest degree to lowest degree.
 */
fun evaluatePolynomial(x: Double, coefficients: List<Double>): Double {
/**
 * This function takes an input value 'x' and a list of coefficients and calculates the value of the polynomial
 * for the given value of 'x'. The coefficients are ordered from highest degree to lowest degree.
 */
fun evaluatePolynomial(x: Double, coefficients: List<Double>): Double {

    val degree = coefficients.size - 1
    var result = 0.0
    var i = degree

    while (i >= 0) {
        result += coefficients[i] * Math.pow(x, (degree - i).toDouble())
        i--
    }

    return result
}