Max power of 2 such that 2^m divides n. (The ruler sequence) Input:

A positive integer N.

Challenge:

Suppose you have a list of integers n = 1, 2 ... N. Output a list of integers, where each number is the maximum power of 2, m, such that 2^m divides each number of n. 



Test cases:

1
0

15
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0

100
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2


This is OEIS A007814.
Python 2, 46 bytes
Saved a couple of bytes thanks to nwellnhof.

lambda k:[len(bin(t+1&amp;~t))-3for t in range(k)]

Try it online!

Python 2, 51 bytes

lambda k:[len(bin(t-~-(t&amp;-~t)))-3for t in range(k)]

Try it online!
How?
The formula for a(k) is log2(k - (k &amp; (k - 1))). That's quite fluffy, but fortunately it can be shortened significantly. In Python, floor(log2(N)) = len(bin(N)) - 3, because bin() appends 0b to the binary representation of an integer. As a side note, len(bin(N))-3 can be replaced by N.bit_length()-1, but that is not really beneficial for golfing purposes. That gives us the opportunity to get rid of the import math and the use of math.log. Another part that can be shortened is k &amp; (k-1). Using more bitwise operations, we get k&amp;~-k instead, and then we subtract this from the actual k. But that would make us iterate over the range [1, k], which would waste bytes because Python lacks inclusive ranges. In order to save a few bytes, we iterate over the integers in [0, k) instead and modify the formula, obtaining k+1-(k&amp;-~k) = k-~-(k&amp;-~k). However, than can be simplified further to k+1&amp;~k (as  @nwellnhof pointed out).