Prime visits doubt

Please tell me the mistake in my code …

Hi @G_rahil,
try modifying ur code. when an input n=2, l=0 and r=1 is given, ur code gives 2 as output i.e acc to ur code 0 and 1 are prime which is not true. Moreover, ur code is interpreting 2 as non prime.
Moreover, u are getting tle in one test case because the approach u r using to solve this problem is the naive approach. Try optimising ur code using sieve of eratosthenes.
Hope dis resolves ur doubt.
If u still face any problem, feel free to post it here.

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.