Can't reduce my time limit for the question of the prime visits what should I do?

Can’t reduce my time limit for the question of the prime visits what should I do??
I’ve tried both 1D array and array list method but both of them are not satisfying the time limit and test case 2.

Use seive for precomputing the primes elements upto 10^7. Then query in 0(1) time to get your solution accepted.

Can you please elaborate the solution for me.

please share your code

https://ide.codingblocks.com/s/180734 —here is the link to my code

dry run your code for input
1
1 100
your code gives 34 whereas the answer should be 25

Use seive for precomputing the primes elements upto 10^7. Then query in 0(1) time to get your solution accepted.

Use seive for precomputing the primes elements upto 10^7. Then query in 0(1) time to get your solution accepted. *****ive got this answer partially , but i can’t yet reduce my time.

@Yuvraj_Luhach Your current code is not correct. Please use seive for precomputing.

@Yuvraj_Luhach please mark your doubt as resolved if are satisfied with the answer