only one test case is passing…whats wrong in my code???..
Prime visits2387
- You don’t need to use ‘long’ anywhere in the code, ‘int’ will work.
- Your code is not efficient for large numbers and will give a Time Limit Exceeded(TLE) Error for such test cases. You need to optimize your algorithm. For example: You can run your loop to check if a number is prime or not upto sqrt(max) instead of till max-1, or try using Sieve of Eratosthenes