GCD
Calculates the greatest common divisor of the given numbers.
- Define a
GCD()function for two numbers, which uses recursion. - Base case is when
yequals0, which returnsx. - Otherwise the GCD of
yand the remainder of the divisionx/yis returned. - Define an overload that accepts multiple numbers or an array and use
IEnumerable.Aggregate()to applyGCD()to them.