fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int gcd(int u, int v)
  6. {
  7. if (v==0)
  8. return u;
  9. else
  10. return gcd(v, u%v);
  11. }
  12.  
  13. int main()
  14. {
  15. int i = 42;
  16. int j = 12;
  17.  
  18. int my_gcd = gcd(i, j);
  19.  
  20. cout << "gcd(" << i << "," << j << ") = " << my_gcd << endl;
  21. cout << "gcd(" << j << "," << 25 << ") = " << gcd(j, 25) << endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
gcd(42,12) = 6
gcd(12,25) = 1