fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int EUC(int a,int b)
  6. {
  7. int buff = 0;
  8. if(b < a)
  9. {
  10. buff = a;
  11. a = b;
  12. b = buff;
  13. }
  14. b = b - a;
  15. return b;
  16. }
  17.  
  18. int main()
  19. {
  20. int a = 0;
  21. int b = 0;
  22. cin >> a >> b;
  23. while(a % b != 0)
  24. {
  25. b = EUC(a,b);
  26. }
  27. cout << b;
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5428KB
stdin
12 8
stdout
4