LC: #2726
Complexity
Time complexity: O(n)

Space complexity: O(n)
Code
# Complexity
- Time complexity: $$O(n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: $$O(n)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```typescript []
class Calculator {
  private value: number;
  private result: number = 0;
  constructor(value: number) {
    this.value = value;
    this.result = value;
  }
  add(value: number) {
    this.result += value;
    return this;
  }
  subtract(value: number) {
    this.result -= value;
    return this;
  }
  multiply(value: number) {
    this.result *= value;
    return this;
  }
  divide(value: number) {
    if (value === 0) {
      throw new Error("Division by zero is not allowed");
    }
    this.result /= value;
    return this;
  }
  power(value: number) {
    this.result **= value;
    return this;
  }
  getResult(): number {
    return this.result;
  }
}
```
```javascript []
var Calculator = /** @class */ (function () {
    /**
     * @param {number} value 
     */
    function Calculator(value) {
        this.result = 0;
        this.value = value;
        this.result = value;
    }
    /**
     * @param {number} value 
     * @returns {Calculator}
     */
    Calculator.prototype.add = function (value) {
        this.result += value;
        return this;
    };
    /**
     * @param {number} value 
     * @returns {Calculator}
     */
    Calculator.prototype.subtract = function (value) {
        this.result -= value;
        return this;
    };
    /**
     * @param {number} value 
     * @returns {Calculator}
     */
    Calculator.prototype.multiply = function (value) {
        this.result *= value;
        return this;
    };
    /**
     * @param {number} value 
     * @returns {Calculator}
     */
    Calculator.prototype.divide = function (value) {
        if (value === 0) {
            throw new Error("Division by zero is not allowed");
        }
        this.result /= value;
        return this;
    };
    /**
     * @param {number} value 
     * @returns {Calculator}
     */
    Calculator.prototype.power = function (value) {
        var _a;
        (_a = this).result = Math.pow(_a.result, value);
        return this;
    };
    /**
     * @returns {number}
     */
    Calculator.prototype.getResult = function () {
        return this.result;
    };
    return Calculator;
}());
```
['TypeScript', 'JavaScript']