Running time of this Program
In the loop, $i$ is repeatedly squared so it will take the values
$$
2, 2^2=4, 4^2=16, 16^2=258, \dotsc
$$
In other words, $i$ will be
$$
2^1, 2^2, 2^4, 2^8, \dots,2^{2^k}
$$
so the loop will iterate $k$ times, until $2^{2^k}\ge n$. Taking the log of this inequality twice we'll have $k\ge \log \log n$ for our running time.