fork download
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int nod(int a, int b){
  7. if (a <= 0 || b <= 0)
  8. return 0;
  9. cout << "OK\n";
  10. int c = 0;
  11. while(b > 0){
  12. cout << a << " " << b << "\n";
  13. c = a % b;
  14. a = b;
  15. b = c;
  16. }
  17. return a;
  18. }
  19. int main()
  20. {
  21. cout << "Result: " << nod(9,15) << "\n";
  22. return 0;
  23. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
OK
9 15
15 9
9 6
6 3
Result: 3