func msb(n) { var b =0while(n >>=1) { ++b }return b}func lsb(n) {msb(n &-n)}
Test cases:
func table (base,power) { var digits =length(base**power)printf("%#{digits}s lsb msb\n",'number')for n in (0..power) { var x = base**nprintf("%#{digits}s %2s %3s\n", x,lsb(x),msb(x)) }}table(42,20)table(1302,20)