# Why in the code i ≃ n?

i=2;
while(i<n)
{
write('*');
i=i*i;
}


Why $$n ≃ i$$?

I mean suppose $$n=1000$$ and so $$i= 2,4,16,32,256,65536$$ is in every steps.

In the book wrote $$2^2 power(k)$$ is pattern for growing $$i$$ so $$n ≃ i$$ and...

Now 65536 or 256 isn't equal to 1000 or around 1000.

But why $$n ≃ i$$?

• How does your source define this notation? It is impossible to answer your question without this knowledge. – Juho Dec 10 '19 at 15:05

The symbol $$\space ≃ \space$$ means "asymptotically equal to".
So when you read $$n ≃ i$$, you can read it as $$n$$ asymptotically approaches $$i$$.
This means that the more $$n$$ increase in size, the more $$i$$ increase in size but $$n$$ never become equal to $$i$$.
I mean suppose $$n=1000$$ and so $$i=2,4,16,32,256,65536$$ is in every steps.
This contains an error: when the program start $$i=2$$. At the first cicle, $$i=2^2 = 4$$. $$\space$$ At the second cicle, $$i=4^2=16$$. $$\space$$ At the third cicle, $$i = 16^2= 256$$. $$\space$$ At the fourth cycle, $$i=256^2 = 65536$$. $$\space$$ At the fifth cycle the program stops since $$i>n$$.
• I think $i$ asymptotically approaches $n$ . because $i$ in every step is go on and $n$ is fixed?!(please see the code) – Michael Dec 10 '19 at 16:34