


public class MathematicalOperations {


    public int binaryPlus(int x,int  y){
        return x+y;
    }

    /**
     * Performs integer subtraction operation
     * @param x The minuend
     * @param y The subtrahend
     * @return The difference
     */
    public int binaryMinus(int x, int y) {
        return x-y;
    }

    public int times(int x, int y){ // returns x*y;
    	return x*y;
    }
    public float divide (int x, int y){// returns x/y as a float
        if(y == 0){
            throw new ArithmeticException("divided by 0");
        }
        return (float)(x)/(float)(y);
    }

    double power(double x, int n){
        if(n==0)
            return 1;
        
        if(n<0){
            x = 1.0/x;
            n = -n;
        }
        double ret = power(x,n/2);
        ret = ret * ret;
        if(n%2!=0)
            ret = ret * x;
        return ret;
    }
    
    public float inverseDivide(int x, int y){
        //returns y/x
        
        if(x == 0){
            throw new ArithmeticException("divided by 0");
        }
        return (float)(y)/(float)(x);
    }
    
    public int remainder(int x, int y) {
    	return x % y;
    }

    public int unaryPlus(int x) {
    	return x;
    }

    public int unaryMinus(int x) {
    	return -x;
    }
    public boolean negation(boolean x) {
        if(x == true){
            return false;
        }else{
            return true;
        }
    }
    
    public int factorial(int x){
        if(x==0 || x==1){
            return 1;
        }else{
            return factorial(x-1)*x;
        }
    }
}

@@ -1472,24 +1472,113 @@
 x)%7B%0A        
+if(x%3C0)%7B%0A            throw new ArithmeticException(%22Undefined factorial%22);%0A        %7Delse 
 if(x==0 %7C%7C x

Update MathematicalOperations.java