I'm writing a program that is spending major amounts of time of CPU doing power operations. I need to get the modulo of $i^j$ by k. Is there any simplification of $i^j$%k that doesn't involve an exponentiation?
Note: I remove the specification about needing to heck divisibility. I actually need to get the modulo so that I can do more things with it.
I will put my two comments in to an answer.
One option is to use the built-in Python function "pow()" and the documentation is found here: https://docs.python.org/3/library/functions.html#pow
Another option is to use the fact that: $(a \cdot b) \mod n = ((a\mod n)\cdot(b\mod n)\mod n)$
So for your case you would have something like: $i^j \mod k = (i \mod k)^j \mod k$