def fast_exponentiation(base, exponent, modulus):
    """
    Applies a fast exponentiation algorithm to the
    given value retrieving the exponentiation result.
    The calculus may be defined by: base ^ exponent % modulus.

    :type base: int
    :param base: The base value for the exponentiation.
    :type exponent: int
    :param exponent: The exponent value for the exponentiation.
    :type modulus: int
    :param modulus: The modulus value for the exponentiation.
    :rtype: int
    :return: The result of the exponentiation.
    """
    result = base % modulus
    remainders = []
    while not exponent == 1:
        remainders.append(exponent & 1)
        exponent >>= 1
    while remainders:
        remainder = remainders.pop()
        result = base ** remainder * result ** 2 % modulus
    return result
