Program to find nth term of the series 1 4 15 24 45 60 92 | 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
< ? php function nthTerm ( $ n ) { $ nth ; if ( $ n % 2 == 0 ) $ nth = 2 * ( ( $ n * $ n ) - $ n ) ; else $ nth = ( 2 * $ n * $ n ) - $ n ; return $ nth ; } $ n = 5 ; echo nthTerm ( $ n ) , " STRNEWLINE " ; $ n = 25 ; echo nthTerm ( $ n ) , " STRNEWLINE " ; $ n = 25000000 ; echo nthTerm ( $ n ) , " STRNEWLINE " ; $ n = 250000007 ; echo nthTerm ( $ n ) , " STRNEWLINE " ; ? >