Good day. It is necessary to override the multiplication operation for the class polynomial. the polynomial itself is given by an array of coefficients and can be of arbitrary length. All the time there are problems with the index out of the array. It feels like everything should be much simpler. but it doesn't get any easier. Thank you in advance
public class Polynom { public int[] coefficients; public Polynom(params int[] coefficients) { this.coefficients = coefficients; } public static Polynom operator * (Polynom polynom1, Polynom polynom2) { int size = polynom1.coefficients.Length + polynom2.coefficients.Length; int[] multiplyCoefficients = new int[size - 1]; int a = polynom1.coefficients.Length; int b = polynom2.coefficients.Length; int c = multiplyCoefficients.Length; if (a>= b) { for (int i=0; i<multiplyCoefficients.Length; i++) { if ((i >= 0) && (i < b)) for (int j = 0; j <= i; j++) { multiplyCoefficients[i] += polynom1.coefficients[j] * polynom2.coefficients[i - j]; } if ((i >= b) && (i < a)) for (int j = b; j <= i; j++) { multiplyCoefficients[i] += polynom1.coefficients[j] * polynom2.coefficients[i - j]; } if ((i >= a) && (i < c)) for (int j = a; j <= i; j++) { multiplyCoefficients[i] += polynom1.coefficients[j] * polynom2.coefficients[i - j]; } } } return new Polynom(multiplyCoefficients); } }