Print the first N terms of the series 6 , 28 , 66 , 120 , 190 , 276 , ... | C ++ program for the above approach ; Function to print the series ; Initialise the value of k with 2 ; Iterate from 1 to n ; Print each number ; Increment the value of K by 2 for next number ; Driver Code ; Given number N ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; void printSeries ( int n ) { int k = 2 ; for ( int i = 0 ; i < n ; i ++ ) { cout << ( k * ( 2 * k - 1 ) ) << " ▁ " ; k += 2 ; } cout << endl ; } int main ( ) { int N = 12 ; printSeries ( N ) ; return 0 ; }