title: Need help printing the powers of two
body: <p>The method printPowersOf2 accepts a max number as the argument and prints each power of 2 from 2^0 up to that max number.</p>
  
  <p>printPowersOf2(3); outputs 1 2 4 8
  printPowersOf2(5); outputs 1 2 4 8 16 32</p>
  
  <p>I can't seem to figure out the right code to print. I have to use a loop and the *= operator. Math class not allowed. I know its something so simple too</p>
  
  <p>Here is my code</p>
  
  <pre><code>public class Chap3LabP2 {
  
  
    public static void main(String[] args) { 
      printPowersof2(3);
      printPowersof2(5);
      printPowersof2(10);
      printPowersof2(12);
  
  
    }
  
    public static void printPowersof2(int maxNum){
      System.out.print("1" + " ");
      for(int i = 1; i &lt;= maxNum; i++){
        System.out.print(i*2 + " ");
      }
  
      System.out.println("");
    }
  
  
  }
  </code></pre>