I'm currently struggling finding the big O complexity of the following source snippet:
private static long algo1(long n){
long counter = 0;
long i = 1;
long x = 1;
while(i < n){
long a = 4*i;
for (long j = a; j >= 1; j--) {
x = x+j;
counter++;
}
i = a/2;
}
return counter;
}
The outer while(i < n)
seems to me to be of complexity log(n). But what's the complexity of the inner for loop?