MCPcopy Create free account
hub / github.com/ActiveState/code / _log2

Function _log2

recipes/Python/252123_Range_minimleast/recipe-252123.py:223–227  ·  view source on GitHub ↗

Make table of logs reach up to n and return floor(log_2(n)).

(n)

Source from the content-addressed store, hash-verified

221
222_logtable = [None,0]
223def _log2(n):
224 """Make table of logs reach up to n and return floor(log_2(n))."""
225 while len(_logtable) <= n:
226 _logtable.extend([1+_logtable[-1]]*len(_logtable))
227 return _logtable[n]
228
229# if run as "python lca.py", run tests on random data
230# and check that RangeMin's results are correct.

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls 1

extendMethod · 0.45

Tested by

no test coverage detected