Rabin karp algorithm

Why does the prime number was taken in the algorithm?
I didn’ t get the concept

@Mansi2103 Constructing a good hash function, involves minimum number of collisions in the input sample, for a same number. So, using prime number reduces the count of collisions, since highly frequent number won’t have prime number as its multiple. You must remember that in the hashing videos also, prime numbers were used.
Please watch the video again to understand it better.

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.