Maximum binomial coefficient term value | Returns value of Binomial Coefficient C ( n , k ) ; Calculate value of Binomial Coefficient in bottom up manner ; Base Cases ; Calculate value using previously stored values ; Return maximum binomial coefficient term value . ; if n is even ; if n is odd ; Driver Code
< ? php function binomialCoeff ( $ n , $ k ) { $ C [ $ n + 1 ] [ $ k + 1 ] = array ( 0 ) ; for ( $ i = 0 ; $ i <= $ n ; $ i ++ ) { for ( $ j = 0 ; $ j <= min ( $ i , $ k ) ; $ j ++ ) { if ( $ j == 0 $ j == $ i ) $ C [ $ i ] [ $ j ] = 1 ; else $ C [ $ i ] [ $ j ] = $ C [ $ i - 1 ] [ $ j - 1 ] + $ C [ $ i - 1 ] [ $ j ] ; } } return $ C [ $ n ] [ $ k ] ; } function maxcoefficientvalue ( $ n ) { if ( $ n % 2 == 0 ) return binomialCoeff ( $ n , $ n / 2 ) ; else return binomialCoeff ( $ n , ( $ n + 1 ) / 2 ) ; } $ n = 4 ; echo maxcoefficientvalue ( $ n ) , " STRNEWLINE " ; ? >