I guess the point is how to avoid overflow. Good algorithms for this does not lead to overflow and return the correct answer; normal ones may easily lead to overflow.
1
Anonimo
15 giu 2012
I guess we need to use Congruences from Number theory here
Anonimo
13 gen 2011
I think there is some point we need to check.
first will x be negative? If so, we need to handle this problem
In addition, in the case y is very large, a O(y) algorithm is not a good idea, we might need to use the O(lg Y) one.
Anonimo
12 gen 2011
result = x mod z
for i = 2 to y do result = (result * x) mod z