Listing 3 (gcd.cpp)

#include <stdlib.h>
#include "mylib.h"

long gcd(long x, long y)
       {
       ldiv_t r;
       x= labs(x);
       if ((y = labs (y)) == 0)
              return x;
       do
              {
              r = ldiv(x, y);
              x = y;
              }
       while ((y = r.rem) !=0);
       return x;
       }

// End of File