> ## Documentation Index
> Fetch the complete documentation index at: https://learn.acadlink.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Factorial Using Recursion

> Calculate factorial of a number using a recursive function.

## Problem Statement

Write a C program to calculate the factorial of a number using recursion.

## Solution

```c theme={null}
#include <stdio.h>

int factorial(int n) {
    if (n <= 1) return 1;
    return n * factorial(n - 1);
}

int main() {
    int n;
    scanf("%d", &n);
    printf("%d! = %d\n", n, factorial(n));
    return 0;
}
```

## Input

```
5
```

## Output

```
5! = 120
```
