• + 1 comment

    In C#

    public class Calculator
    {
        public int power(int num, int pow)
        {
            if(num < 0 || pow < 0)
                throw new Exception("n and p should be non-negative");
                
            return (int)Math.Pow(num, pow);
        }
    }