Ways to place 4 items in n ^ 2 positions such that no row / column contains more than one | Function to return the number of ways to place 4 items in n ^ 2 positions ; Driver code
< ? php function NumberofWays ( $ n ) { $ x = ( 1 * ( $ n ) * ( $ n - 1 ) * ( $ n - 2 ) * ( $ n - 3 ) ) / ( 4 * 3 * 2 * 1 ) ; $ y = ( 1 * ( $ n ) * ( $ n - 1 ) * ( $ n - 2 ) * ( $ n - 3 ) ) ; return ( 1 * $ x * $ y ) ; } $ n = 4 ; echo NumberofWays ( $ n ) ; ? >