fast exponentiation. Miller-Rabbin prime test