Prime visits problem

sir what is the mistake in this code
it is not passing only one test case

You have to use Sieve of Eratosthenes for primes in this problem. The test cases are large and so without this it will give TLE. Lecture video of Sieve of Eratosthenes is there in the Number Theory section of your course. Please refer that first and then try to solve this problem using that concept.

You can refer this: https://www.youtube.com/watch?v=8sniiDbfPK4