Advertisement
thesonpb

ước chung lớn nhất

Mar 30th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int ucln(int m, int n){
  4.     if(m>n) return ucln(m-n, n);
  5.     if(m<n) return ucln(m, n-m);
  6.     if(m==n) return m;
  7. }
  8. int main(){
  9.     int m, n;
  10.     cin >> m >> n;
  11.     if(ucln(m, n)!=1) cout<<"NO";
  12.     else cout<<"YES";
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement