* fix: remove isHidden flag from frontmatter * fix: add isUpcomingChange Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com> * feat: hide blocks not challenges Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com> Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
1.6 KiB
1.6 KiB
id, title, isRequired, challengeType, forumTopicId
id | title | isRequired | challengeType | forumTopicId |
---|---|---|---|---|
a302f7aae1aa3152a5b413bc | Factorialize a Number | true | 5 | 16013 |
Description
n!
For example: 5! = 1 * 2 * 3 * 4 * 5 = 120
Only integers greater than or equal to zero will be supplied to the function.
Instructions
Tests
tests:
- text: <code>factorialize(5)</code> should return a number.
testString: assert(typeof factorialize(5) === 'number');
- text: <code>factorialize(5)</code> should return 120.
testString: assert(factorialize(5) === 120);
- text: <code>factorialize(10)</code> should return 3628800.
testString: assert(factorialize(10) === 3628800);
- text: <code>factorialize(20)</code> should return 2432902008176640000.
testString: assert(factorialize(20) === 2432902008176640000);
- text: <code>factorialize(0)</code> should return 1.
testString: assert(factorialize(0) === 1);
Challenge Seed
function factorialize(num) {
return num;
}
factorialize(5);
Solution
function factorialize(num) {
return num < 1 ? 1 : num * factorialize(num - 1);
}
factorialize(5);