import java.util.*; //引入包
public class JC{
static int multi(int v){ //方法类
int i;
int m=1;
for(i=1;i<=v;i++)
m=m*i;
return m;
}
public static void main(String[] args){ //java的入口
Scanner scanner =new Scanner(System.in);
System.out.println("输入一个数求取它的阶乘:");
int number=scanner.nextInt();
long rl;
rl=(long)multi(number); //调用方法
System.out.println(+number+"!="+rl);
}
}
输出结果: