using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace bai_4_sgkt26
{
class Program
{
static int UCLN(int a, int b)
{
while (a != b)
{
if (a > b) UCLN(a - b, b);
if (a < b) UCLN(a,a-b);
}
return a;
}
static void Main(string[] args)
{
int a, b,c,d,max,max1,max2;
Console.Write("nhap a="); a = int.Parse(Console.ReadLine());
Console.Write("nhap b="); b = int.Parse(Console.ReadLine());
Console.Write("nhap c="); c = int.Parse(Console.ReadLine());
Console.Write("nhap d="); d = int.Parse(Console.ReadLine());
max1= UCLN(a, b);
max2=UCLN(c,d);
max = UCLN(max1, max2);
Console.Write("uoc so chung lon nhat la:"+max);
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace bai_4_sgkt26
{
class Program
{
static int UCLN(int a, int b)
{
while (a != b)
{
if (a > b) UCLN(a - b, b);
if (a < b) UCLN(a,a-b);
}
return a;
}
static void Main(string[] args)
{
int a, b,c,d,max,max1,max2;
Console.Write("nhap a="); a = int.Parse(Console.ReadLine());
Console.Write("nhap b="); b = int.Parse(Console.ReadLine());
Console.Write("nhap c="); c = int.Parse(Console.ReadLine());
Console.Write("nhap d="); d = int.Parse(Console.ReadLine());
max1= UCLN(a, b);
max2=UCLN(c,d);
max = UCLN(max1, max2);
Console.Write("uoc so chung lon nhat la:"+max);
Console.ReadKey();
}
}
}