Added my works from 2022
This commit is contained in:
27
alg_4_1.cpp
Normal file
27
alg_4_1.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
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()
|
||||
{
|
||||
int a, b;
|
||||
cin >> a >> b;
|
||||
|
||||
cout << gcd_recur(a, b);
|
||||
}
|
||||
Reference in New Issue
Block a user