namespace LensSimulatorCore.MathsLib; public static class CoreMaths { public static double CalculateLCM(double num1, double num2) { // Find the greater and lesser numbers double greaterNum = Math.Max(num1, num2); double lesserNum = Math.Min(num1, num2); // Calculate LCM using the formula: LCM = (num1 * num2) / GCD(num1, num2) double lcm = (greaterNum * lesserNum) / CalculateGCD(greaterNum, lesserNum); // Return the LCM return lcm; } public static double CalculateGCD(double num1, double num2) { // Euclidean algorithm to calculate GCD while (num2 != 0) { double temp = num2; num2 = num1 % num2; num1 = temp; } // Return the GCD return num1; } public static List SolveQuadratic(double a, double b, double c) { var solutions = new List(); double discriminant = b * b - 4 * a * c; if (discriminant < 0) { // If the discriminant is less than zero, then there are no real solutions return solutions; } else { // Calculate both solutions double sqrtDiscriminant = Math.Sqrt(discriminant); double solution1 = (-b + sqrtDiscriminant) / (2 * a); double solution2 = (-b - sqrtDiscriminant) / (2 * a); solutions.Add(solution1); solutions.Add(solution2); return solutions; } } }