eolymp
bolt
Try our new interface for solving problems
Problems

Recursion - 1

published at 4/22/24, 8:16:45 pm

include <iostream>

using namespace std; class Demo{ private: int n; public: void setNum(int n){ this->n = n; } int getNum(){ return n; } }; int main() { Demo d; double n, s=0; cin >> n; if (n==0){ cout<<0; }else if (n>0){ while (n!=0){ s+=n; n--; } cout<<s; } return 0; }