#J (10)
J (10)
Very, very, very inspired by the answer of @Dennis:
<.@%~^&1.5
And a slightly longer, but with better performance (I suspect):
<.@(-:&.^.)
floor(halve under log)
To execute, indented parts are input:
f=:<.@%~^&1.5
f 0 8 12 16
0 2 3 4
g=:<.@(-:&.^.)
g 0 8 12 16
0 2 3 4