The Factorial Engine
Medium+25 XP
Mission Briefing
The Alchemist's latest potion requires an exact factorial measurement of ingredients to prevent an explosion.
The Concept: Accumulators
Instead of starting with 0 and adding, you can start an accumulator variable at 1 and multiply it inside a loop. A factorial of n (written as n!) is the product of naturally descending numbers. E.g., 4! = 4 * 3 * 2 * 1 = 24.
The Objective
Your function receives a number n.
- Use a loop to calculate the factorial of
n. - Return the final calculated product.
Constraints
FundamentalsLoops
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
n4
Expected Output
24
Click RUN to test your solution