View Code of Problem 610

#include<iostream>
#include<cmath>
using namespace std;

int main(){
    int n;
    int a[20]={0};
    a[1]=1;
          for (int i = 2; i < 11; i++)
          {
              a[i]=a[i-1]+pow(3,i-2);
          }
    while(cin>>n){
       
          cout<<a[n]<<endl;
          
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 610