-
Description One char less ~~
Code const factorial = n => n < 2 ? 1 : n * factorial(n - 1);
Test Cases const chai = require("chai"); const assert = chai.assert; describe("Solution", function() { it("should test for something", function() { assert(factorial(0), 1); assert(factorial(5), 120); assert(factorial(8),40320); assert(factorial(15),1307674368000); }); });
Output:
-
Code const factorial = n => n <= 1 ? 1 : n * factorial(n - 1);- const factorial = n => n < 2 ? 1 : n * factorial(n - 1);
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}