
// calculates a Factorial
public class Counter
{
public static void main(String [] args)
   {

   int z;      // z is the counter
   int Total;  // Total will hold the ongoing product

   z = 1;
   Total = 1;

   while (z <= 50)
      {
      Total = Total * z;
      System.out.println("z is " + z + " and Factorial is " + Total ); 
      z = z + 1;

      if (Total < 0)
         {
         System.out.println("Computer memory over-run!!!");
         System.exit( 0 );
         }

      } // end while z <= 100

   } // end main
} // end class Counter
