Advertisement
Mirbek

GCD

Jan 3rd, 2022
1,105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int gcd(int a, int b) {
  6.     if (!b)
  7.         return a;
  8.     return gcd(b, a % b);
  9. }
  10.  
  11. int main(){
  12.     int a, b;
  13.     cin >> a >> b;
  14.  
  15.     cout << gcd(a, b) << endl;
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement