public static int divide(int a, int b) {
        if (a == 0) return 0;
        if (b == 0) throw new IllegalArgumentException("Divisor is zero!");
        int absA = abs(a), absB = abs(b);
        boolean isNegative = a > 0 != b > 0;
        int sum = 0, result = 0;
        while (add(sum, absB) <= absA) {
            sum = add(sum, absB);
            result = add(result, 1);
        }
        return isNegative ? negate(result) : result;
    }