private static int GcdCore(CalcGcdDelegat calc, params int[] param) { if (param.Length < 2) { throw new ArgumentException(); } if (param.Length == 2) { return(calc.Invoke(param[0], param[1])); } int[] newParam = new int[param.Length / 2 + 1]; if (param.Length % 2 != 0) { newParam[param.Length / 2] = param[param.Length - 1]; } for (int i = 0; i < newParam.Length - 1; i++) { newParam[i] = calc.Invoke(param[2 * i], param[2 * i + 1]); } return(GcdCore(calc, newParam)); }
private static int GcdCore(CalcGcdDelegat calc, int firstNumber, int secondNumber, int thirdNumber) => calc.Invoke(calc.Invoke(firstNumber, secondNumber), thirdNumber);