Count tiles of dimensions 2 * 1 that can be placed in an M * N rectangular board that satisfies the given conditions | Function to count tiles of dimensions 2 x 1 that can be placed in a grid of dimensions M * N as per given conditions ; Number of tiles required ; Driver Code
function numberOfTiles ( n , m ) { if ( n % 2 == 1 ) { return - 1 ; } return ( m * n ) / 2 ; } var n = 2 , m = 4 ; document . write ( numberOfTiles ( n , m ) ) ;