1
$\begingroup$
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$?

This chapter is about notations.

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

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$.

$\endgroup$
  • $\begingroup$ I think $i$ asymptotically approaches $n$ . because $i$ in every step is go on and $n$ is fixed?!(please see the code) $\endgroup$ – Michael Dec 10 '19 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.