import math


class Calculator:
    '''
    '''

    __DEPLOY_TAG = "master"
    __DEPLOY_TIMESTAMP = "2019-08-07 19:49:02"

    def __init__(self):
        print("Init Calculator")

    def add(self, a, b):
        return a + b

    def subtract(self, a, b):
        return a - b

    def multiply(self, a, b):
        return a * b

    def divide(self, a, b):
        return a / b

    def power(self, base, exp):
        return base ** exp

    def factorial(self, n):
        if not n >= 0:
            raise ValueError("n must be >= 0")

        if math.floor(n) != n:
            raise ValueError("n must be exact integer")

        if n+1 == n:  # catch a value like 1e300
            raise OverflowError("n too large")

        result, factor = 1, 2

        while factor <= n:
            result *= factor
            factor += 1

        return result
