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
Anónimo
15 de jun de 2012
I guess we need to use Congruences from Number theory here
Anónimo
13 de ene de 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.
Anónimo
12 de ene de 2011
result = x mod z
for i = 2 to y do result = (result * x) mod z