#include<bits/stdc++.h>
      using namespace std;
      int getSum(int n)
      {
          if(n==0) 
              return n;
          return n + getSum(n-1);
      }
      int main()
      {
          int n;
          cout << "Enter a number : "; 
          cin >> n;
          int sum = getSum(n);
          cout << sum;
          return 0;
      }
      
      Cpp language logo

      sum

      0

      0

      avatar
      Ayush Gupta

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.