Home My space log
Language EN (English)

Factorial

JavaScript Intermediate alien ages 11-13

The problem

The factorial of n (written n!) is 1 x 2 x 3 x ... x n. For example 5! = 5 x 4 x 3 x 2 x 1 = 120. Write a function factorial(n) that gives it back. 0! is 1.

You will practice: loops, multiplying, building up a result

Mode

Press Tab to indent. Press Esc and then Tab to move on to the next button.

Your code runs in your browser. We do not receive it or save it.

Test results

      What your code printed