49. 阶乘
语法讲解
今天学: 阶乘就是从 1 连续乘到 n。例如 5! = 1*2*3*4*5 = 120。
public class Main {
public static void main(String[] args) {
int result = 1;
for (int i = 1; i <= 5; i++) {
result *= i;
}
System.out.println(result);
}
}
小练习
输出是什么?
提交要求: 只提交最终输出结果,不要添加多余的说明或引号。
全部评论