# n-th term in series 2, 12, 36, 80, 150….in C++

C++Server Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

66 Lectures 5.5 hours

The given series is 2, 12, 36, 80, 150...

If you clearly observe the series, you will find that the n-th number is n2 + n3.

## Algorithm

• Initialise the number N.
• Use the series formula to compute the n-th term.
• Print the result.

## Implementation

Following is the implementation of the above algorithm in C++

#include <bits/stdc++.h>

using namespace std;

int getNthTerm(int n) {
return (n * n) + (n * n * n);
}
int main() {
int n = 7;
cout << getNthTerm(n) << endl;
return 0;
}

## Output

If you run the above code, then you will get the following result.

392
Updated on 22-Oct-2021 07:46:48