Recursion/Programs/sum_n.cpp
// takes O(n) time complexity
//recursive funtion to find sum of n natural numbers
takes O(n) time complexity
recursive funtion to find sum of n natural numbers
takes O ( n ) time complexity recursive funtion to find sum of n natural numbers
int sum_n(int n)
{
    if(n==0)
    {
        return 0;
    }
    else
    {
        return sum_n(n-1)+n;
    }
}
int sum_n ( int n ) { if ( n == 0 ) { return 0 ; } else { return sum_n ( n - 1 ) + n ; } }
takes O(n) time complexity
recursive funtion to find sum of n natural numbers
takes O ( n ) time complexity recursive funtion to find sum of n natural numbers