import edu.rice.cs.mint.runtime.Code;
import edu.rice.cs.mint.runtime.SafeCode;

public class Power_Rec {
    public static void main(String[] args){        
        System.out.println(power(2, 17));
        PowerFun spower17 = <| new PowerFun() {
            public int power(final int x){
                return `(power2(<|x|>, 17));
            }
        } |>.run();
        
        System.out.println(spower17.power(2));
    }
    
    public static int power(int x, int n){
        if (n == 1)
            return x;
        else
            return x * power(x, n-1);
    }
    
    public static separable SafeCode<Integer> power2(SafeCode<Integer> x, int n){
        if (n == 1)
            return x;
        else
            return <| `x * `(power2(x, n-1)) |>;
    }
    
    public static abstract class PowerFun{
        public abstract int power(int x);
    }
}

