title: how to get exponents without using the math.pow for java
body: <p>This is my program</p>
  
  <pre><code>// ************************************************************
      // PowersOf2.java
      //
      // Print out as many powers of 2 as the user requests
      //
      // ************************************************************
  
      import java.util.Scanner;
  
      public class PowersOf2 {
  
      public static void main(String[] args)
  
      {
          int numPowersOf2; //How many powers of 2 to compute
          int nextPowerOf2 = 1; //Current power of 2
          int exponent= 1;
          double x;
  
           //Exponent for current power of 2 -- this
          //also serves as a counter for the loop Scanner
  
          Scanner scan = new Scanner(System.in);
          System.out.println("How many powers of 2 would you like printed?");
          numPowersOf2 = scan.nextInt();
          System.out.println ("There will be " + numPowersOf2 + " powers of 2 printed");
          //initialize exponent -- the first thing printed is 2 to the what?
  
      while( exponent &lt;= numPowersOf2)
          {
          double x1 = Math.pow(2, exponent);
          System.out.println("2^" + exponent + " = " + x1);
                  exponent++;
          }   
  //print out current power of 2
  //find next power of 2 -- how do you get this from the last one?
  //increment exponent
  
      }
  }
  </code></pre>
  
  <p>The thing is that I am not allowed to use the math.pow method, I need to find another way to get the correct answer in the while loop. </p>