阶乘计算器

n! = n × (n−1) × … × 1

Factorial Calculate

📐 计算公式
阶乘(本页代码口径):n!=1×2×…×n 逐次累乘(n 经 Math.round 取整,负数按 0 处理即结果 1);联动量:科学计数值、完整整数、ln(n!)、几何平均 (n!)^(1÷n)。校验:n>170 提示「n 不能超过 170:171! 已超出双精度浮点上限(约 1.8×10³⁰⁸)」并终止。判据:无固定分级,n! 增长快于指数,约 70! 已超 10¹⁰⁰,170! 为双精度可表示上限。

非负整数的阶乘,0! = 1。

Formula & Standard References

Item Formula / Note Source / Standard
Factorial n! = n · (n-1) · ... · 1, with the convention 0! = 1 ISO 80000-2:2019, Quantities and units - Part 2: Mathematics
Recurrence n! = n · (n-1)! ISO 80000-2:2019, Quantities and units - Part 2: Mathematics
Stirling approximation n! ≈ sqrt(2·pi·n) · (n/e)^n Stirling J., Methodus Differentialis (1730)
Relation to the gamma function Gamma(n + 1) = n!, extending the factorial to non-integer arguments NIST Digital Library of Mathematical Functions §5.2
📌 计算说明
  • 0! = 1。
  • 10! = 3,628,800。

📚 深度解析:阶乘 n!

💡 常见使用场景

基本计算
5!=5×4×3×2×1=120;0!=1(约定,使公式自洽,如 C(n,0)=1)。
溢出提示
20!≈2.43×10^18,超过 64 位整数上界;更大阶乘需用对数或近似(斯特林公式 n!≈√(2πn)(n/e)^n)。

❓ 常见问题(FAQ)

为什么 0! = 1?
这是约定也是组合含义:从 n 个里选 0 个只有 1 种方式(什么都不选),且使 C(n,0)=n!/(0!×n!)=1 自洽。
阶乘增长有多快?
极快,近似指数中的指数级。10!=3628800,20! 已超 2×10^18,远超普通整数范围,大数需用对数或近似计算。

📊 结果解读

结果含义

阶乘 n! = 1×2×…×n(0!=1),表示 n 个不同元素的全排列数;增长极快,13! 已超 60 亿。

边界

普通数值类型在 n≈170 附近溢出;大数阶乘需高精度/对数近似(log(n!))。本工具按支持范围计算,超限会提示。