There is no formula for this calculation as per my knowledge. Since the number of executions duplicates with a set of number. I have done a simulation on this upto 2 power 20 numbers. Below is the python code
1.for n= 2 Count is 0
2.for n= 4 Count is 1
3.for n= 8 Count is 2
4.for n= 16 Count is 2
5.for n= 32 Count is 3
6.for n= 64 Count is 3
7.for n= 128 Count is 3
8.for n= 256 Count is 3
9.for n= 512 Count is 4
10.for n= 1024 Count is 4
11.for n= 2048 Count is 4
12.for n= 4096 Count is 4
13.for n= 8192 Count is 4
14.for n= 16384 Count is 4
15.for n= 32768 Count is 4
16.for n= 65536 Count is 4
17.for n= 131072 Count is 5
18.for n= 262144 Count is 5
19.for n= 524288 Count is 5
Code
__author__ = 'Abhilash'
import math
i = 2;
n = 2048
k=[2,4,8,16,32,64,128,256,512,1024,2048,4096, 8192 , 16384 , 32768 , 65536 , 131072 , 262144 , 524288 ]
for b in range(0,20):
print int(math.pow(2,b)),",",
x=0
for b in range(0,len(k)):
n=k[b]
x=0
i=2
while i < n:
i=i*i
x=x+1
print "for n=",n,"