View Code of Problem 3834

#include<bits/stdc++.h>
using namespace std;
long long 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;
	while(cin>>n){
	long long sum=dp(n);
	cout<<sum<<endl;
}
}

Double click to view unformatted code.


Back to problem 3834