fork download
  1. #include <iostream>
  2. using namespace std;
  3. int NWD(int a, int b)
  4. {
  5. int r;
  6. while(b>0)
  7. {
  8. r=a%b;
  9. a=b;
  10. b=r;
  11. }
  12. return a;
  13. }
  14. int x,y;
  15. int main() {
  16. cin>>x>>y;
  17. cout<<NWD(x,y);
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5512KB
stdin
24 36
stdout
12