Campaign/Level 7 of 12
easyRecursion1 bug

Recursion Without a Floor

factorial(0) crashes the server with "Maximum call stack size exceeded".

factorial(n) returns n! for n ≥ 0. factorial(0) is 1.

Fix the code so every test passes. Keep the function name factorial.

Test cases

  • factorial(5) → 120
  • factorial(1) → 1
  • factorial(0) → 1
  • factorial(3) → 6

Hints

each hint costs XP

Stuck? Hints go from a nudge to the exact fix.