Added Exponentiation by squaring algorithm