title: How do I not print the multiplication sign at the end of the factorial expression for loop?
body: <p>I created a program in java that takes an int as an input and prints its factorial. For example input = 5 printed: 5 x 4 x 3 x 2 x 1 = 120. However, I can't find a way to get rid of the multiplication sign at the end of it. I get: 5 x 4 x 3 x 2 x 1 x = 120. What can I do to get rid of it only at the end? Here's my code:</p>
  
  <pre><code>import java.util.*;
  public class Factorial {
  public static void factorial(int input)
  {
      int sum = 1;
      for(int i = input; i&gt;=1; i--)
      {
          System.out.print(i+" x ");
          sum *= i;
  
      }
      System.out.print(" = " + sum);
  }
  
  public static void main (String []args)
  {
      Scanner in = new Scanner (System.in);
      System.out.println("Enter a number to obtain its factorial");
      int a = in.nextInt();
      factorial(a);
  
  }
  }
  </code></pre>