Create a binary ruler Given a number n, generate the first n columns of this pattern:

                               #
               #               #
       #       #       #       #
   #   #   #   #   #   #   #   #
 # # # # # # # # # # # # # # # #
################################ ...


The height of the column at (1-indexed) n is the number of trailing 0 bits in n's binary representation, plus one. As a result, the bottom layer has every column filled in, the second layer every second column, the third layer every fourth column, etc.

Rules


You may input and output through any standard method.
You may assume the input is an integer between 1 and 999, inclusive.
The output may contain any amount of whitespace, as long as the pattern is intact.
The pattern must be 1-indexed, and in the same format as shown here.
You may use any single non-whitespace character in place of #, but you may not change the space character.


Test cases

1
#

2
 #
##

3
 # 
###

4
   #
 # #
####

5
   # 
 # # 
#####

7
   #   
 # # # 
#######

32
                               #
               #               #
       #       #       #       #
   #   #   #   #   #   #   #   #
 # # # # # # # # # # # # # # # #
################################


A few larger test cases can be found here.

Scoring

This is code-golf, so the shortest code in bytes in each language wins.
Python 2, 54 bytes



i=n=input()
while i:i-=1;print((' '*~-2**i+'#')*n)[:n]


Try it online!

Prints with lots of leading whitespace. Each row i counting down from n repeats a pattern of 2**i-1 spaces followed by a #. This pattern is repeated up to the width of the ruler, which is the input n. This is done by multiplying the pattern string by n and taking the first n characters with [:n].

The pattern can be made by string formatting for an equal length alternative.

i=n=input()
while i:i-=1;print('%%%ds'%2**i%'#'*n)[:n]


A cute slicing method is longer.

n=input();s=~-2**n*' '+'#'
exec"s=s[1::2]*2;print s[:n];"*n