Algorithms·easy 10 min 50 XP
Factorial
Return n! (the product of all positive integers up to n). 0! is 1.
Examples
- factorial(5) → 120
- factorial(0) → 1
Constraints
- Keep the required function name so the tests can find it
- Return a value instead of only logging it
- Do not mutate inputs unless the challenge asks you to
Factorial · editor
Code runs in an isolated Web Worker with a 3-second timeout — no DOM access, and it can never hang the page.