Program to print the series 1 , 9 , 17 , 33 , 49 , 73 , 97. . . till N terms | Java implementation of the above approach ; Function to print the series ; Generate the ith term and print it ; Driver Code
import java . util . * ; class GFG { static 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 ; System . out . print ( ith_term + " , ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 7 ; printSeries ( N ) ; } }