This is the code:
j=2 while j<(n*n) j=j*j
At first my approach was to treat this like this loop
i=1 while (i<n) i=i*2
Which generates on $i$ various powers of $2$ ($i=2^0, 2^1, 2^2....2^k$).
At a certain $k$ iteration, $i$ is equal to or exceeds $n$.
So $2^k=n$ is the time when the
We find $k=log_2(n)$ which is the number of times the entire
while loop has been executed, so $T(n)=\theta(log_2n)$.
So my idea for the first algorithm was this:
j=j*j generates on $j$ different powers of himself, so you can describe it as $j^2$. The problem is that I can't shove in a $k$ iterations in the counting.
The solution for this is actually $log(log(n))$.
Why is this? Can I improve my logic?