time limit exceeding after using the SQRT method also plz explain why?
Prime visits : time limit exceeding after using the SQRT
By just checking till the square root of the number, sure you have reduced the number of checks. However the code is still not efficient for larger values. Hence the TLE.
Check out sieve of eratosthenes for an efficient solution.