code: static long multiplyFraction(long x, long numerator, long denominator) {
      if (x == 1) {
        return numerator / denominator;
      }
      long commonDivisor = gcd(x, denominator);
      x /= commonDivisor;
      denominator /= commonDivisor;
      // We know gcd(x, denominator) = 1, and x * numerator / denominator is exact,
      // so denominator must be a divisor of numerator.
      return x * (numerator / denominator);
    }
docs: Returns (x * numerator / denominator), which is assumed to come out to an integral value.