added fast exponentiation algorithm