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
static int GCD(int a, int b)
{
if (b == 0) return a;
return GCD(b, a % b);
}
static int GCD(params int[] numbers)
{
int gcd = 0;
int a = numbers[0];
for(int i = 1; i < numbers.Length; i++)
{
gcd = GCD(a, numbers[i]);
a = numbers[i];
}
return gcd;
}