Program to print the series 1 , 9 , 17 , 33 , 49 , 73 , 97. . . till N terms | C ++ implementation of the above approach ; Function to print the series ; Generate the ith term and print it ; Driver Code
#include " bits / stdc + + . h " NEW_LINE using namespace std ; void printSeries ( int N ) { int ith_term = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { ith_term = i % 2 == 0 ? 2 * i * i + 1 : 2 * i * i - 1 ; cout << ith_term << " , ▁ " ; } } int main ( ) { int N = 7 ; printSeries ( N ) ; return 0 ; }