title: how to remove a character on last run of for loop in java
body: <p>I'm trying to get rid of the asterisk (*) from the output on the last run of the for loop, it should print </p>
  
  <blockquote>
    <p>5 * 4 * 3 * 2 * 1   is 120</p>
  </blockquote>
  
  <p>But it actually prints </p>
  
  <blockquote>
    <p>5 * 4 * 3 * 2 * 1 *  is 120</p>
  </blockquote>
  
  <p>can anyone help me out? </p>
  
  <pre><code>public static void getFactorial(){
      Scanner sc = new Scanner (System.in);
  
      int number = 0;
      int factorial = 1;
      int count;
  
      System.out.println("Welcome to option 2 "  + yourName + ": Calculate a factorial.");
      System.out.println("Enter a number: ");
      number = sc.nextInt();
      System.out.println();
  
      if (number &gt; 0)
      {
          for (count=number; count&gt;0; count--) //count starts same as number, loops until it gets to 1
          {
              if(count &gt; 1)
                  factorial = factorial*count;
              System.out.print(count + " * ");
  
              if(count == 1)
                  System.out.print(" is "+factorial);
              System.out.print("");
  
          }
  
      }
  
      else if (number&lt;=0)
      {
          System.out.println("Please enter a number greater than 0.");
      }
      else
      {
          System.out.println("Please enter a whole number");
      }
  </code></pre>