title: how does gcd program calculate the result correctly
body: <pre><code>    class GcdCal {
  public:
      int gcd(int a,int b){
          if(a&lt;b){
              int temp =a;
              a = b;
              b = temp;
          }
          int r = a%b;
          if(r == 0){
              cout&lt;&lt; b;
          }else{
              //cout&lt;&lt; b&lt;&lt; "   "&lt;&lt; r&lt;&lt;" *** ";
              gcd(b,r);
          }
          return b;
      }
  };
  
  int main() {
      int a= 44;
      int b= 16;
      GcdCal numberTest;
      int result = numberTest.gcd(a,b);
      cout&lt;&lt; result;
      cout&lt;&lt;"gcd is "&lt;&lt;result;
  }
  </code></pre>
  
  <p>I am a new man of C++, I just wanted to calculate the gcd with C++, but the program output the wrong result, instead 4 but 16,sometimes even 0, I don't know where is wrong.</p>