Find the sum of natural numbers with and without recursion | faceprep

Find the sum of natural numbers with and without recursion | faceprep

The program to find the sum of natural numbers with and without recursion is discussed in this article. A number, N is obtained as input and the sum of the first N natural numbers is given as output.


Find the sum of natural numbers with and without recursion

Program to find the sum of natural numbers without using recursion


@@coding::1@@


Time Complexity: O(n)


Find the sum of natural numbers with and without recursion

Program to find the sum of natural numbers using recursion


@@coding::2@@


Time Complexity: O(n)


Find the sum of natural numbers with and without recursion


Recommended Programs










Find the sum of natural numbers with and without recursion

c