Please check where i am i wrong in my sollution
There is nothing wrong with your code. It’s just taking more time than expected. You have to use the concept of sieve of eratosthenes in this question. You can find about that concept in the Number Theory section of the course.
Hope this helps.