Skip to content

Factorial · ⁨阶乘⁩

English

Factorial

The factorial n! is the product 1 * 2 * 3 * ... * n. By definition 0! is 1.

Start a result at 1, then multiply it by every integer from 2 up to n in a loop. (The tests keep n at most 10, so the answer fits in an int.)

中文

阶乘

阶乘 n! 是连乘积 1 * 2 * 3 * ... * n。按照定义,0! 等于 1。

把结果初始化为 1,然后用循环把它依次乘以从 2 到 n 的每个整数。(测试中 n 最大为 10,所以结果能放进一个 int。)

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩