Find Nth term of the series 1 , 6 , 18 , 40 , 75 , ... . | Java code to generate ' Nth ' term of this sequence ; Function to generate a fixed number ; ( N ^ 2 * ( N + 1 ) ) / 2 ; Driver Method
class GFG { public static int nthTerm ( int N ) { int nth = 0 ; nth = ( N * N * ( N + 1 ) ) / 2 ; return nth ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . println ( nthTerm ( N ) ) ; } }