Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
53483 | littletwleve | 求1+2+3+... | C++ | Accepted | 0 MS | 248 KB | 164 | 2024-10-23 14:16:54 |
#include<bits/stdc++.h> using namespace std; int sum(int n){ if(n==1) return 1; else return n+sum(n-1); } int main(){ int x; cin>>x; cout<<sum(x); }