to check the large prime loop is iterated from i=0 to i<prime.size() to check n%i==0 .Is prime.size() return the value sqrt(n)?
To find the largest prime
@Kumarrituranjan2056
What we have done here is, first we have calculated prime sieve till 10^7 and store all prime numbers till 10^7 in prime array. Then for checking whether the number No is prime or not, we are checking if No is divisible by any of prime number till 10^7 (which is stored in prime array). That’s we have to iterated from i=0 to i<prime.size().
It doesn’t mean prime.size() is same as sqrt(No).
1 Like
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.