public static int lcm(int[] x)
{
if (x.Length < 2)
{
throw new System.InvalidOperationException("Do not use this method if there are less than" + " two numbers.");
}
int tmp = lcm(x[x.Length - 1], x[x.Length - 2]);
for (int i = x.Length - 3; i >= 0; i--)
{
if (x[i] <= 0)
{
throw new System.ArgumentException("Cannot compute the least " + "common multiple of " + "several numbers where " + "one, at least," + "is negative.");
}
tmp = lcm(tmp, x[i]);
}
return tmp;
}