using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a, b, num1, num2, temp;
Console.WriteLine("Please input two numbers:");
num1 = Convert.ToInt32(Console.ReadLine());
num2 = Convert.ToInt32(Console.ReadLine());
if (num1 < num2)/*交换两个数,使大数放在num1上*/
{
temp = num1;
num1 = num2;
num2 = temp;
}
a = num1; b = num2;
while (b != 0)/*利用碾除法,直到b为0为止*/
{
temp = a % b;
a = b;
b = temp;
}
Console.WriteLine("最大公约数是:{0}",a);
Console.WriteLine("最小公倍数是:{0}",num1*num2/a);
}
}
}