循环增量的复杂性2

JR *_*lia 2 algorithm complexity-theory

以下循环的时间复杂度是多少?

for(int i=1; i<=n; i=i*2){
    System.out.println("*");
}
Run Code Online (Sandbox Code Playgroud)

是对数吗?

seh*_*ehe 6

所示的算法将是 O(log n)

由于迭代次数是log2(n),或log10(n)/log10(2)