Skip to content

Factorial (mind the size) · ⁨阶乘(注意大小)⁩

English

Factorial (mind the size)

n! is 1 × 2 × … × n, and 0! is 1. It grows fast — 20! is over two billion billion — so the method returns a long, not an int, or the answer would overflow. Multiply from 2 up to n.

中文

阶乘(注意大小)

n! 是 1 × 2 × … × n,而 0! 是 1。它增长很快 —— 20! 超过两百亿亿 —— 所以这个方法返回 long 而不是 int,否则结果会溢出。从 2 乘到 n。

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

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