for ( ll j=ii;j<1000000;j+=i);
i did’t get the functioning of this code used in prime sieve concept
value of i is not changing so how this code is working .
in the first run when i =3 implies j=32=9 and j is then initialized to j=j+i=9+3=12
in then second run j=i*I and iis still 3 so again j will be equal to 9 so how is it running?
then in second
I have problem prime sieve code
Hi @vipuljaiswal, this for loop for (ll j=i * i;j<1000000; j+=i) is running inside another for loop which changes the value of i so, we have different value of i in each run . let me show you the snippet
for (int i=3; i *i <=1000000; i+=2)
{
// If prime[p] is not changed, then it is a prime
if (prime[p] == true)
{
// Update all multiples of p greater than or
// equal to the square of it
// numbers which are multiple of p and are
// less than p^2 are already been marked.
for (int j=i *i; j<=1000000; j += p)
prime[i] = false;
}
}
In case of any doubt feel free to ask 
mark your doubt as resolved if you got the answer
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.