-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlec5_gcd.cpp
More file actions
45 lines (30 loc) · 728 Bytes
/
lec5_gcd.cpp
File metadata and controls
45 lines (30 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
https://www.geeksforgeeks.org/problems/gcd-of-two-numbers3459/1?utm_source=geeksforgeeks&utm_medium=article_practice_tab&utm_campaign=article_practice_tab
//{ Driver Code Starts
#include<bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution {
public:
int gcd(int a, int b) {
if(b == 0)
{
return a;
}
return gcd(b , a%b);
}
};
//{ Driver Code Starts.
int main(){
int t;
scanf("%d ",&t);
while(t--){
int a;
scanf("%d",&a);
int b;
scanf("%d",&b);
Solution obj;
int res = obj.gcd(a, b);
cout<<res<<endl;
}
}
// } Driver Code Ends