Prime visits : time limit exceeding after using the SQRT

time limit exceeding after using the SQRT method also plz explain why?

link: https://ide.codingblocks.com/s/74351

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.