Run Error in Prime Visits

So, my code is executed well but my doubt is that if I set the size of prime boolean array to b i.e. prime[b] instead of prime[b+1] then I have got the run time error. I didn’t get it. Why???

@Kinjal hey kinjal your code works fine for small input as your code is not optimize well as I can see your looping part is creating issues.

Like how? Do you think that my code can be optimize more, I dont have idea, man. Do you have any suggestion about optimization?

@Kinjal hey kinjal see this see this function how it’s work

here is the edited code:


Can you check, what’s wrong with the code?
But, your logic is good. The whole idea is that prime numbers are the subset of odd integers. Isn’t it?

@Kinjal hey kinjal follow this structure to avoid tle

code

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.