using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine(請輸入一個數:); int num1 = int.Parse(Console.ReadLine()); Console.WriteLine(請輸入另一個數:); int num2 = int.Parse(Console.ReadLine()); int tmp; if (num1 < num2) { tmp = num1; num1 = num2; num2 = tmp; } int a = num1; int b = num2; while (b != 0) { tmp = a % b; a = b; b = tmp; } Console.WriteLine({0}和{1}的最大公約數為:{2},num1,num2,a); Console.WriteLine({0}和{1}的最小公倍數為:{2},num1,num2,num1*num2/a); } } }