Prime Visits problem


I am not understanding where should count be initialized so as to give the correct answer.Please help.

@srshubhi398

make the prime sieve once and then
simple iterate over the range [a,b] and count no of nmbers which are prime

1 Like

thamkyou ,I understood that I needed to use prime sieve but was my logic incorrect or was there any other error in my code?

it was a brute approach and given the constraints it will give tle
u can utilise the knowledge of sieve of eratosthenes in this question

1 Like

Thanks a lot for the suggestion.

1 Like

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.