Suppose we are given two integer numbers p and q. We have to find out the value of 22^p mod q. The output has to be an integer.
So, if the input is like p = 5, q = 6, then the output will be 4
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def solve(p, q): res = pow(2, 2 ** p, q) return res print(solve(5, 6))