public static EuclidEntity ExtendEuclid(int a, int b) { if (b == 0) { return(new EuclidEntity { D = a, X = 1, Y = 0 }); } EuclidEntity preEuclidEntity = ExtendEuclid(b, a % b); return(new EuclidEntity { X = preEuclidEntity.Y, D = preEuclidEntity.D, Y = preEuclidEntity.X - (a / b) * preEuclidEntity.Y }); }
static void Main(string[] args) { EuclidEntity euclidEntity = ExtendEuclid(99, 78); Console.WriteLine($"{euclidEntity.X}*99 + {euclidEntity.Y}*78 = {euclidEntity.D}"); }