Large prime Check

for finding the number that is larger than 10^7,
why we are checking the divisibility of no by ony prime numbers only .

for(long long int i=0;primes[i]*primes[i]<=no;i++)
{
if(no%primes[i]==0)
{
return false;
}
}
,
Not able to understand the concept ?
please explain.

To prove that a number n is not prime we just need to show that it is divisible by atleast one number between 2 to n-1, so the moment we find the first divisor we break from the loop.

Yes you are saying right, but what bhaiya was saying in video,I’d not understood.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.