# How to write a c program to find the sum of natural numbers using recursion

How to write a __c program__ to find the sum of natural numbers using recursion. In this program, you will learn how to find the sum of natural numbers using recursion.

Take an example to find the sum through a __c program__:

```
// How to write a c program to find the sum of natural numbers using recursion
#include <stdio.h>
int recSum(int x);
int main() {
int x;
// x - dnotes a positive number
printf("-----Enter a positive number to get the sum-----\n");
scanf("%d", &x);
printf("\nThe Sum is: %d\n", recSum(x));
return 0;
}
int recSum(int n) {
if (n)
return n + recSum(n - 1);
else
return n;
}
```

**Output:**

`-----Enter a positive number to get the sum-----`

36

`The Sum is: 666`

## Tags:

# how to write a c program to find factorial of a number using recursion

# how to write a c program to print n natural numbers using recursion

# how to write a program in c to calculate the sum of numbers from 1 to n using recursion.