Finding n | Java Program to Finding n - th term of series 3 , 13 , 42 , 108 , 235 . . . ; Function to generate a fixed number ; Driver Method
class GFG { public static int magicOfSequence ( int N ) { int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) sum += ( i * i * i + i * 2 ) ; return sum ; } public static void main ( String args [ ] ) { int N = 4 ; System . out . println ( magicOfSequence ( N ) ) ; } }