从控制台输入一个正整数,计算该数的阶乘
public class test03{
public static void main(String[] args){
java.util.Scanner s= new java.util.Scanner(System.in);
System.out.println("请输入一个正整数:");
int i = s.nextInt();
int sum = 1;
System.out.print("阶乘为");
for(int j=i;j>0;j--){
sum =sum*j;
if(j!=1){
System.out.print(j+"*");
}else{
System.out.print(j);
}
}System.out.print("="+sum);
}
}