* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.2 KiB
1.2 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
a302f7aae1aa3152a5b413bc | Factorialize a Number | 5 | 16013 | 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.
assert(typeof factorialize(5) === 'number');
factorialize(5)
should return 120.
assert(factorialize(5) === 120);
factorialize(10)
should return 3628800.
assert(factorialize(10) === 3628800);
factorialize(20)
should return 2432902008176640000.
assert(factorialize(20) === 2432902008176640000);
factorialize(0)
should return 1.
assert(factorialize(0) === 1);
--seed--
--seed-contents--
function factorialize(num) {
return num;
}
factorialize(5);
--solutions--
function factorialize(num) {
return num < 1 ? 1 : num * factorialize(num - 1);
}
factorialize(5);