Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
15586 | 马德理666 | 求1+2+3+... | C++ | Accepted | 0 MS | 240 KB | 191 | 2023-04-23 22:43:15 |
//601158 - 求1+2+3+... #include <bits/stdc++.h> using namespace std; int fun(int n){ if(n<2){ return 1; } return fun(n-1)+n; } int main(){ int n; cin>>n; cout<<fun(n); }