c++ - Not sure what this recursive function returns -
i reading recursive functions, , have been trying figure out mathematical formula one. thought maybe logarithmic function, not seem it. if point me in right direction, appreciate it.
unsigned f(unsigned n){ if(n<2) return 1; return 1 + f(n/2); }
it logarithm function, base 2. more specifically, it's ceil
1 + floor(log2(n))
.
Comments
Post a Comment