Prime visits problem

getting tle in prime visits problem given in hackerblocks .
here is the code:


please tell me where i am going wrong

Hi @Raghavsingla522 try using a better method like prime sieve to solve this problem.

ya i will try that . @gayatri20 but can you please tell me how to pass the remaining test case using my approach ?

@Raghavsingla522 your code is not passing the rest of the test cases because the time complexity for your code is
O(n^2) which is not efficient, so you have to try putting something more efficient to reduce the complexity.