text: Permutation Coefficient | A O ( n ) time and O ( 1 ) extra space PHP solution to calculate the Permutation Coefficient ; Compute n ! and ( n - k ) ! ; Driver Code
code: < ? php function PermutationCoeff ( $ n , $ k ) { $ Fn = 1 ; $ Fk ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { $ Fn *= $ i ; if ( $ i == $ n - $ k ) $ Fk = $ Fn ; } $ coeff = $ Fn / $ Fk ; return $ coeff ; } $ n = 10 ; $ k = 2 ; echo " Value ▁ of ▁ P ( " , $ n , " , ▁ " , $ k , " ) STRNEWLINE TABSYMBOL TABSYMBOL is ▁ " , PermutationCoeff ( $ n , $ k ) ; ? >