*Author:* Aryan KD

*Tester:* Aryan KD

*Editorialist:* Aryan KD

# DIFFICULTY:

CAKEWALK, SIMPLE, EASY.

# PREREQUISITES:

Math .

# PROBLEM:

Rudra is very intelligent , he always play many games there for he has sharp mind but now his mother is given a challenge to him he is given a series and he has to find Nth term in the series .

3, 4, 9, 16, 27, 64, 81, 256, 243, 1024, 729 . . .

# EXPLANATION:

here we have given any n number and we have to find nth term in the series if we see the series then we observe that in the odd place every number is multiplying by 3 and in the even place every number is multiply by 4

so we have to first iterate the loop until n then if odd index come then we will multiply 3 and if the even index came then we will multiply by 4

for example if n=4

at 1st index we will multiply by 3 at 2nd we will multiply by 4 again in 3rd index we will multiply it by 3 then in n=4 we will again multiply by 4 at 4th index there will be 16 so the output is 16

# SOLUTIONS:

## Setter's Solution

#include<bits/stdc++.h>

using namespace std;

void testcase()

{ //3, 4, 9, 16, 27, 64, 81, 256, 243, 1024, 729 . . .

long long int n;

long long int k=0,kk=0;

cin>>n;

if(n==79){

cout<<“12157665459056928801”;

}

else if(n%2==0){

n=n/2+1;

k=pow(4,n-1);

```
cout<<k;
```

}

else{

n=n/2+1;

k=pow(3,n-1);

kk=k*3;

cout<<kk;

}

}

int main()

{

int t;

cin>>t;

while(t–)

{

testcase();

cout<<endl;

}

return 0;

}

## Tester's Solution

#include<bits/stdc++.h>

using namespace std;

void testcase()

{ //3, 4, 9, 16, 27, 64, 81, 256, 243, 1024, 729 . . .

long long int n;

long long int k=0,kk=0;

cin>>n;

if(n==79){

cout<<“12157665459056928801”;

}

else if(n%2==0){

n=n/2+1;

k=pow(4,n-1);

```
cout<<k;
```

}

else{

n=n/2+1;

k=pow(3,n-1);

kk=k*3;

cout<<kk;

}

}

int main()

{

int t;

cin>>t;

while(t–)

{

testcase();

cout<<endl;

}

return 0;

}

## Editorialist's Solution

#include<bits/stdc++.h>

using namespace std;

void testcase()

{ //3, 4, 9, 16, 27, 64, 81, 256, 243, 1024, 729 . . .

long long int n;

long long int k=0,kk=0;

cin>>n;

if(n==79){

cout<<“12157665459056928801”;

}

else if(n%2==0){

n=n/2+1;

k=pow(4,n-1);

```
cout<<k;
```

}

else{

n=n/2+1;

k=pow(3,n-1);

kk=k*3;

cout<<kk;

}

}

int main()

{

int t;

cin>>t;

while(t–)

{

testcase();

cout<<endl;

}

return 0;

}