/**************************
Meno a Priezvisko : Milan Caban
Datum : 13.0.11.10.1
Uloha : CW18/24 PSEUDOCODE_6: Euklides
PSEUDOKOD :
Vstup: Celá kladná čísla x a y
1. a ← x, b ← y
2. Opakujeme:
3. Pokud a < b, prohodíme a s b.
4. Pokud b = 0, vyskočíme z cyklu.
5. a ← a mod b / zbytek po dělení
Výstup: Největší společný dělitel a = gcd(x, y)
******************************/
using System;
class Program
{
static void Main()
int x = 45;
int y = 18;
int gcd = FindGCD(x, y);
Console.WriteLine($"The greatest common divisor of {x} and {y} is {gcd}.");
}
static int FindGCD(int x, int y)
int a = x;
int b = y;
while (true)
if (a < b)
(a, b) = (b, a);
if (b == 0)
break;
a = a % b;
return a;