30 lines
446 B
C++
30 lines
446 B
C++
#include <iostream>
|
|
|
|
int gcd_recur(int n1, int n2)
|
|
{
|
|
if (n1 == n2)
|
|
{
|
|
return n1;
|
|
}
|
|
|
|
if (n1 > n2)
|
|
{
|
|
return gcd_recur(n1-n2, n2);
|
|
}
|
|
else
|
|
{
|
|
return gcd_recur(n1, n2-n1);
|
|
}
|
|
}
|
|
|
|
int main()
|
|
{
|
|
setlocale(LC_ALL, "Russian");
|
|
int a, b;
|
|
|
|
std::cout << "Введите два числа для определения НОД: ";
|
|
std::cin >> a >> b;
|
|
|
|
std::cout << "НОД: " << gcd_recur(a, b) << std::endl;
|
|
}
|