Skip to content

Commit ec4afff

Browse files
committed
recursion
1 parent 059a6ee commit ec4afff

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

recursion/add_number_n.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
////https://codeforces.com/contest/266/problem/A
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
typedef long long ll;
5+
const int mod = 1e9 + 7;
6+
const int N = 1e5 + 5;
7+
8+
int solve(int n){
9+
if(n==1) return 1;
10+
return solve(n-1)+n;
11+
}
12+
13+
int main() {
14+
ios_base::sync_with_stdio(0);
15+
cin.tie(0);
16+
cout << solve(7) <<endl;
17+
}

0 commit comments

Comments
 (0)