In this problem, we are given an integer value N. Our task is to find the nth term of the series −
0, 8, 64, 216, 512, 1000, 1728, 2744…
Let’s take an example to understand the problem,
Input: N = 6 Output: 1000
Solution Approach
To find the Nth term of the series, we need to closely observe the series. The series is the cube of even numbers, where the first term is 0.
So, the series can be decoded as −
[0]3, [2]3, [4]3, [6]3, [8]3, [10]3…
For ith term,
T1 = [0]3 = [2*(1-1)]3
T2 = [2]3 = [2*(2-1)]3
T3 = [4]3 = [2*(3-1)]3
T4 = [6]3 = [2*(4-1)]3
T5 = [8]3 = [2*(5-1)]3
So, the Nth term of the series is { [2*(N-1)]3 }
Example
Program to illustrate the working of our solution
#include <iostream>
using namespace std;
long findNthTermSeries(int n){
return ((2*(n-1))*(2*(n-1))*(2*(n-1)));
}
int main(){
int n = 12;
cout<<n<<"th term of the series is "<<findNthTermSeries(n);
return 0;
}Output
12th term of the series is 10648