title: Convert number to byte with N bits set
body: <p>I have a number in range 1-8.</p>
  
  <p>I want to convert it to</p>
  
  <pre><code>0b00000001  // 1
  0b00000011  // 2
  0b00000111  // 3
  0b00001111  // 4
  0b00011111  // 5
  0b00111111  // 6
  0b01111111  // 7
  0b11111111  // 8
  </code></pre>
  
  <p>Can it be done without a switch or a for loop?
  Ideally with a simple formula.</p>