power_by_squaring(x,p): fix failures for large p.

Previously 7^typemax(Int) would hang forever. Now:

	julia> 7^typemax(Int)
	7905747460161236407

	julia> 7*ans
	1

Since typemax(Int) is the size of the multiplicative group of all
integers modulo 2^64, this is particularly useful as it gives you
the multiplicative inverse of 7 (or whatever number).