Finding n | C ++ program to find n - th term of series 3 , 13 , 42 , 108 , 235. . . ; Function to generate a fixed number ; Driver Method
#include <bits/stdc++.h> NEW_LINE using namespace std ; int magicOfSequence ( int N ) { int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) sum += ( i * i * i + i * 2 ) ; return sum ; } int main ( ) { int N = 4 ; cout << magicOfSequence ( N ) << endl ; return 0 ; }