Query regarding rehashing

how will i make thye table size of the table as the next prime number in rehashing , will i need to do it using the prime sieve or something more optimised

@Parmeet-Kalsi-1631789033630118 you can make use sieve of erastothenes and store all primes in an array or vector, then you can get nearest prime number to any given number using binary search in the array where you stored the primes.
Eg: array of primes: 2,3,5,7,11,13,17…
nearest smaller prime to 16 is 13.

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.