java - complexity of simple algorithm -
i have following algorithm dont know its' complexity. me? input size n.
int x = n; while (x > 0) { system.out.println("value is" + x); x = x/5; } thanks lot!
in each iteration x divided 5. how many iterations take x become lower 1 (and therefore 0)?
the answer log5(n) (logarithm base 5 of n), o(log(n)).
Comments
Post a Comment