There are several questions on Stack Overflow discussing how to find the Greatest Common Divisor of two values. One good answer shows a neat recursive function
GCD(a, b, c) = GCD(a, GCD(b, c)) = GCD(GCD(a, b), c) = GCD(GCD(a, c), b)
enter code here
public class Program { static void Main() { Console.WriteLine(GCD(new[] { 10, 15, 30, 45 })); } static int GCD(int a, int b) { return b == 0 ? a : GCD(b, a % b); } static int GCD(int[] integerSet) { return integerSet.Aggregate(GCD); } }