int num1, num2, temp;
num1 = Convert.ToInt32(Console.ReadLine());
num2 = Convert.ToInt32(Console.ReadLine());
temp = Math.Max(num1, num2);
num2 = Math.Min(num1, num2);//num2中放较小的数
num1 = temp;//num1中放较大的数
int result=num1*num2;
if (num1 * num2 != 0)
{
while (num2 != 0)
{
num1 = (num1 > num2) ? num1 : num2;
int i = num1 % num2;
num1 = num2;
num2 = i;
}
Console.WriteLine("最小公倍数为:"+(result)/num1);
}
Console.ReadKey(); |