using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSharp001
{
class Program
{
static void Main(string[] args)
{
int a, b, m, n, temp;
Console.WriteLine("Please input two numbers:");
string strM = Console.ReadLine();
string strN = Console.ReadLine();
m = Convert.ToInt32(strM);
n = Convert.ToInt32(strN);
if (m < n)
{
temp = m;
m = n;
n = temp;
}
a = m; b = n;
while (b != 0)
{
temp = a % b;
a = b;
b = temp;
}
Console.WriteLine("最大公约数:" + a);
Console.WriteLine("最小公倍数:" + n * m / a);
}
}
}
运行结果: