import java.util.Scanner;
public class Factorial2 {
public static void main( String[] args ) {
Scanner input = new Scanner(System.in);
int n = 0;
int fac = 1;
int i;
System.out.print("n? ");
n = input.nextInt();
for (int j = n ; j > 0; j--)
System.out.print( j + "*");
for (i = 1 ; i <= n ; i++){
fac = fac*i;
}
System.out.print(" = " + fac );
}
}
OUTPUT:
n? 3
3*2*1* = 6
How do I remove the last * like 3 * 2 * 1 = 6 That's what the output I want. Is there any function or other ways to solve it?