← Back to challenges

Recursion: Factorials

JavaScriptHardrecursionnumbers

Instructions

Write a function that calculates the factorial of a number recursively.

Examples

factorial(5) ➞ 120

factorial(3) ➞ 6

factorial(1) ➞ 1

factorial(0) ➞ 1

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Sort Numbers in Ascending Order