To validate whether any given number x is prime or not, actually, we do not need to check for all the numbers between 2 and x. we can actually check if x is a multiple of any number between 2 and sqrt(x), if yes then the number is not a prime number.

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________