fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. unsigned long long f(unsigned long long n, unsigned long long m) {
  5. if (n % m == 0) return m;
  6. if (m % n == 0) return n;
  7. if (m > n) f(m % n, n);
  8. else f(n % m , m);
  9. }
  10.  
  11. int main() {
  12. unsigned long long n, m, t;
  13. cin >> m >> n;
  14. t = f(m, n);
  15. cout << t;
  16. return 0;
  17. }
Success #stdin #stdout 0s 4180KB
stdin
6 3
stdout
3