Calculate (x^y)%z without pow() -- Google