12 Replies Latest reply: Mar 6, 2011 10:32 PM by 841370 RSS

    Powers of 7 from 0 to 30

    844463
      Hi guys,

      I want to print this out below-

      7 ^ 0 = 1
      7 ^ 1 = 7
      7 ^ 2 = 49
      ------------
      ------------
      7 ^ 30 =

      I tried below code but it doesn't produce what I want -


      public class PowersOfSeven {

      public static void main (String [] args) {

      int power = 1;

      for (int count = 0; count <= 30; count++){

      System.out.println ("7 ^ " + count + " = " + power);

      power = power * 7;

      }

      }
      }


      Could anyone please help me to figure out how to solve this issue?

      Thanks.