juniorRecursion

Calculate Factorial using Recursion.

Updated Apr 28, 2026

Short answer

n! = n * (n-1)! with base case 0! = 1.

Deep explanation

Recursion allows for elegant solutions to hierarchical problems. n! = n * (n-1)! with base case 0! = 1. However, it requires careful handling of the stack to prevent memory exhaustion.

Real-world example

Traversing a family tree.

Common mistakes

  • Forgetting the base case, leading to infinite recursion.

Follow-up questions

  • What is the space complexity?

More Recursion interview questions

View all →