title: Generating all integers n which n&m==n(m is a given integers) effeciently in C
body: <p>&amp; is bit AND in C.</p>
  
  <p>Example: </p>
  
  <pre><code>m= 21(10101)
  </code></pre>
  
  <p>The result:</p>
  
  <pre><code>0 16 4 1 20 5 17 21
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>for(int i=0;i&lt;=m;i++) 
      if ((i&amp;m)==i) printf("%d ",i);
  </code></pre>
  
  <p>This will be very slow when m is large. </p>
  
  <p>How to find the result quickly (when answer is very few, such as m=2^30)?</p>