fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int x, y, m;
  6. cin >> x >> y;
  7. if (x < y) swap(x, y);
  8. while( y !=0){
  9. m = x % y;
  10. x = y;
  11. y = m;
  12. }
  13. cout << x;
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5280KB
stdin
20
8
stdout
4