1// gcd function definition below:
2int gcd(int a, int b) {
3 if (b == 0)
4 return a;
5 return gcd(b, a % b);
6}
7
8int a = 105, b = 30;
9cout<<"GCD of "<< a <<" and "<< b <<" is "<< gcd(a, b);
10// output = "GCD of 105 and 30 is 15";
1#include<iostream>
2using namespace std;
3long long gcd(long long a, long long b)
4{
5 if (b == 0)
6 return a;
7 return gcd(b, a % b);
8
9}
10int main()
11{
12 long long a,b;
13 cin>>a>>b;
14 cout<<gcd(a,b);
15}
1#include<bits/stdc++.h>
2using namespace std;
3long long UCLN(long long a,long long b)
4{
5 long long r;
6 while (b!=0)
7 {
8 r=a%b;
9 a=b;
10 b=r;
11 }
12 return a;
13}
14
15
16int main()
17{
18 long long a, b;
19 cout<< "enter: ";
20 cin>> a;
21 cout<< "enter: ";
22 cin >>b;
23 cout<<UCLN(a,b)<<endl;
24 return 0;
25}