title: Writing all powers of 2 not exceeding given number
body: <p>here is the code.</p>
  
  <pre><code>int n,power=2;
  cin&gt;&gt;n;
  cout&lt;&lt;power&lt;&lt;endl;
  while(power&lt;n){
  power=power*2;
  cout&lt;&lt;power&lt;&lt;endl;
  }
  </code></pre>
  
  <p>For example, if i wrote 20, the output should be "2 4 8 16". Instead, it writes me "2 4 8 16 32" What should i change in this code? Thanks.</p>