Your first for loop got ias a series:

The first loop stops when the last element of this series is greater than or equal to N:

xmeans how many times the first cycle is executed. Now we are trying to find x:

Where

Yes, this is how you say:
The first for-loop will run log (n) times
The second body of the cycle works as the sum:

, O (n)
2N-1 , N : 1, 2, 4, 8, ... , 2^n
, .