Program to find nth term of the series 1 4 15 24 45 60 92 | Javascript implementation of the above approach ; function to calculate nth term of the series ; variable nth will store the nth term of series ; if n is even ; if n is odd ; return nth term ; Driver code
using System ; class GFG { function nthTerm ( n ) { let nth ; if ( n % 2 == 0 ) nth = 2 * ( ( n * n ) - n ) ; else nth = ( 2 * n * n ) - n ; return nth ; } let n = 5 ; document . write ( nthTerm ( n ) + " " ) ; n = 25 ; document . write ( nthTerm ( n ) + " " ) ; n = 25000000 ; document . write ( nthTerm ( n ) + " " ) ; n = 250000007 ; document . write ( nthTerm ( n ) + " " ) ;