Function to return the number of ways to arrange K different objects taking N objects at a time
function countArrangements ( $ n , $ k , $ p ) { return ( factorial ( $ n , $ p ) * nCrModP ( $ k , $ n , $ p ) ) % $ p ; }