String Matching Rabin-Karp

For Small Prime Numbers, Answer is Coming Correct, but Why Does it Give Wrong Answer for Big Prime Numbers?
If I Take Larger Primes, Execution Becomes Faster but After a Limit Starts Giving Wrong Output.

hello @rtg67GHu_67,
Inetger overflow might be the reason.

prime^exponent can be really very big for larger value of prime

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.