fixed fast exponentiation algorithm for the case of modulus 0