public static int lcm(int x1, int x2)
{
if (x1 <= 0 || x2 <= 0)
{
throw new System.ArgumentException("Cannot compute the least " + "common multiple of two " + "numbers if one, at least," + "is negative.");
}
int max, min;
if (x1 > x2)
{
max = x1;
min = x2;
}
else
{
max = x2;
min = x1;
}
for (int i = 1; i <= min; i++)
{
if ((max * i) % min == 0)
{
return i * max;
}
}
throw new System.InvalidOperationException("Cannot find the least common multiple of numbers " + x1 + " and " + x2);
}