Wednesday, 18 September 2013

Log base n of x

Log base n of x

I have a little problem. who knows how we can calculate the log base n (2
for example: for n=2 we had this solution:
int log(int n){
int res = 0;
while((n>>=1))
res++;
return res;
}

No comments:

Post a Comment