public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//输入提示语句
System.out.print(“请输入一个小于10的数:”);
//从键盘获取值
int num = input.nextInt();
//定义一个总和
int sum = 1;
//开始判断输入数是否小于10
if(num>0&&num<10){
//计算阶乘
for (int i = 1; i <=num; i++) {
sum *=i;
}
System.out.print(num+“的阶乘为:”+sum);
}else {
System.out.println(“您输入数字有误!”);
}
}
}