chore: import upstream snapshot with attribution
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
This commit is contained in:
+73
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: a302f7aae1aa3152a5b413bc
|
||||
title: Factorialize a Number
|
||||
challengeType: 1
|
||||
forumTopicId: 16013
|
||||
dashedName: factorialize-a-number
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
Return the factorial of the provided integer.
|
||||
|
||||
If the integer is represented with the letter `n`, a factorial is the product of all positive integers less than or equal to `n`.
|
||||
|
||||
Factorials are often represented with the shorthand notation `n!`
|
||||
|
||||
For example: `5! = 1 * 2 * 3 * 4 * 5 = 120`
|
||||
|
||||
Only integers greater than or equal to zero will be supplied to the function.
|
||||
|
||||
# --hints--
|
||||
|
||||
`factorialize(5)` should return a number.
|
||||
|
||||
```js
|
||||
assert.isNumber(factorialize(5));
|
||||
```
|
||||
|
||||
`factorialize(5)` should return `120`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(factorialize(5), 120);
|
||||
```
|
||||
|
||||
`factorialize(10)` should return `3628800`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(factorialize(10), 3628800);
|
||||
```
|
||||
|
||||
`factorialize(20)` should return `2432902008176640000`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(factorialize(20), 2432902008176640000);
|
||||
```
|
||||
|
||||
`factorialize(0)` should return `1`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(factorialize(0), 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function factorialize(num) {
|
||||
return num;
|
||||
}
|
||||
|
||||
factorialize(5);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function factorialize(num) {
|
||||
return num < 1 ? 1 : num * factorialize(num - 1);
|
||||
}
|
||||
|
||||
factorialize(5);
|
||||
```
|
||||
Reference in New Issue
Block a user