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}
1int gcd(int a, int b)
2{
3 // Everything divides 0
4 if (a == 0)
5 return b;
6 if (b == 0)
7 return a;
8 // base case
9 if (a == b)
10 return a;
11 // a is greater
12 if (a > b)
13 return gcd(a-b, b);
14 return gcd(a, b-a);
15}
1#include<iostream>
2using namespace std;
3
4int euclid_gcd(int a, int b) {
5 if(a==0 || b==0) return 0;
6 int dividend = a;
7 int divisor = b;
8 while(divisor != 0){
9 int remainder = dividend%divisor;
10 dividend = divisor;
11 divisor = remainder;
12 }
13 return dividend;
14}
15
16int main()
17{
18 cout<<euclid_gcd(0,7)<<endl;
19 cout<<euclid_gcd(55,78)<<endl;
20 cout<<euclid_gcd(105,350)<<endl;
21 cout<<euclid_gcd(350,105)<<endl;
22 return 0;
23}
1#include <stdio.h>
2int main()
3{
4 int t, n1, n2, gcd;
5 scanf("%d", &t); // Test Case Input
6 while (t--)
7 {
8 scanf("%d %d", &n1, &n2);// Taking numbers input
9
10 if (n2 > n1)
11 {
12
13 gcd = n1;
14 n1 = n2;
15 n2 = gcd;
16 }
17 while (n1 % n2 != 0)
18 {
19 gcd = n2;
20 n2 = n1 % n2;
21 n1 = gcd;
22 }
23 // n2 is our gcd
24 printf("GCD: %d\n", n2);
25 }
26 return 0;
27}