View Code of Problem 3834

#include<bits/stdc++.h>
using namespace std;
int dp(int n){
	if(n==2){
		return 5;
	}
	else if(n==1){
		return 2;
	}
	else if(n>2){
		return dp(n-1)*3-1;
	}
}
int main(){
	int n;
	cin>>n;
	cout<<dp(n)<<endl;
}

Double click to view unformatted code.


Back to problem 3834