46 lines
1.0 KiB
Markdown
Raw Normal View History

---
id: a302f7aae1aa3152a5b413bc
title: 对一个数字进行推理
challengeType: 5
videoUrl: ''
---
# --description--
返回提供的整数的阶乘。如果整数用字母n表示则阶乘是所有小于或等于n的正整数的乘积。因子通常用简写符号`n!`表示`n!`例如: `5! = 1 * 2 * 3 * 4 * 5 = 120`只有大于或等于零的整数才会被提供给该函数。如果卡住,请记得使用[Read-Search-Ask](https://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck-coding/19514) 。编写自己的代码。
# --hints--
`factorialize(5)`应该返回一个数字。
```js
assert(typeof factorialize(5) === 'number');
```
`factorialize(5)`应该返回120。
```js
assert(factorialize(5) === 120);
```
`factorialize(10)`应返回3628800。
```js
assert(factorialize(10) === 3628800);
```
`factorialize(20)`应该返回2432902008176640000。
```js
assert(factorialize(20) === 2432902008176640000);
```
`factorialize(0)`应该返回1。
```js
assert(factorialize(0) === 1);
```
# --solutions--