1 solutions

  • 0
    @ 2025-11-5 18:35:14

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int n,sum=0,y=1;
        cin>>n;
        while(n--){
            sum+=y;
            if(n==0) break;
            y++; 
        }
        cout<<sum;
        return 0;
    } 
    
    • 1

    Information

    ID
    18939
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By