C Program to Find Sum of Natural Numbers using Recursion Last Updated : 08 Jun, 2023 Comments Improve Suggest changes Like Article Like Report Natural numbers include all positive integers from 1 to infinity. There are multiple methods to find the sum of natural numbers and here, we will see how to find the sum of natural numbers using recursion. Example Input : 5Output : 15Explanation : 1 + 2 + 3 + 4 + 5 = 15 Input : 10Output : 55Explanation : 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55 ApproachGiven a number n, To calculate the sum, we will use a recursive function recSum(n).BaseCondition: If n<=1 then recSum(n) returns the n. Recursive call: return n + recSum(n-1).Program to find the sum of Natural Numbers using Recursion Below is the implementation using recursion: C // C program to find the sum of n // natural numbers using recursion #include <stdio.h> // Returns the sum of first n // natural numbers int recSum(int n) { // Base condition if (n <= 1) return n; // Recursive call return n + recSum(n - 1); } // Driver code int main() { int n = 10; printf("Sum = %d ", recSum(n)); return 0; } OutputSum = 55 The complexity of the above method Time complexity: O(n). Auxiliary space: O(n). Comment More infoAdvertise with us Next Article C Program to Find Sum of Natural Numbers using Recursion M mukulsomukesh Follow Improve Article Tags : C Programs C Language C Basic Programs Similar Reads C Program to Calculate Sum of Natural Numbers Here we will build a C program to calculate the sum of natural numbers using 4 different approaches i.e. Using while loopUsing for loopUsing recursionUsing Functions We will keep the same input in all the mentioned approaches and get an output accordingly. Input: n = 10 Output: 55 Explanation: The s 3 min read Sum of array Elements without using loops and recursion Given an array of N elements, the task is to find the Sum of N elements without using loops(for, while & doWhile) and recursion.Examples: Input: arr[]={1, 2, 3, 4, 5} Output: 15 Input: arr[]={10, 20, 30} Output: 60 j Approach: Unconditional Jump Statements can be used to solve this problem.Uncon 5 min read C Program For Adding Two Numbers Represented By Linked Lists- Set 2 Given two numbers represented by two linked lists, write a function that returns the sum list. The sum list is linked list representation of the addition of two input numbers. It is not allowed to modify the lists. Also, not allowed to use explicit extra space (Hint: Use Recursion). Example : Input: 6 min read C Program to Print Fibonacci Series The Fibonacci series is the sequence where each number is the sum of the previous two numbers of the sequence. The first two numbers are 0 and 1 which are used to generate the whole series.ExampleInput: n = 5Output: 0 1 1 2 3Explanation: The first 5 terms of the Fibonacci series are 0, 1, 1, 2, 3.In 4 min read C/C++ program for calling main() in main() Given a number N, the task is to write C/C++ program to print the number from N to 1 by calling the main() function using recursion.Examples: Input: N = 10 Output: 10 9 8 7 6 5 4 3 2 1Input: N = 5 Output: 5 4 3 2 1 Approach:Use static variable to initialise the given number N.Print the number N and 2 min read Like