why are we doing ii ?
/////////////////////////////
for(int i=2;ii<=n;i++) in for loop ?
Inside code (i*i) in loop
because if we analyse any number
eg
36 -> factors are 2 , 3 , 4, 6 , 13,12,9,6
all prime factor occur before the square root of the number which can be written either as
i <= sqrt(n) or
i * i <= n
so for optimisiation purpose we do
i* i <= n
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.