using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
int sayi1, sayi2;
Console.WriteLine(“1. Sayiyi giriniz”);
sayi1=Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“2. Sayiyi giriniz”);
sayi2 = Convert.ToInt32(Console.ReadLine());
GCD(sayi1, sayi2);
Console.ReadKey();
}
public static void GCD(int x, int y)
{
int bolucu = 2;
int GCD = 1;
while (!(x == 1 && y == 1))
{
if (x % bolucu == 0 && y % bolucu == 0) //iki sayıyı da bölüyorsa GCD ile çarp
{
GCD = GCD * bolucu;
x = x / bolucu;
y = y / bolucu;
}
else if (x % bolucu == 0) { x = x / bolucu; } //sayılardan birini bölüyorsa bölünen sayıyı değiştir.
else if (y % bolucu == 0) { y = y / bolucu; }
else { bolucu++; } // ne zaman bölücü iki sayıyı da bölemiyorsa bolucuyu artır.
}
Console.WriteLine(“en büyük ortak böleni {0}”, GCD);
}
}
}