Minimum number of square tiles required to fill the rectangular floor | Function to find the number of tiles ; If breadth is divisible by side of square ; Tiles required is N / s ; One more tile required ; If length is divisible by side of square ; Tiles required is M / s ; One more tile required ; Input length and breadth of rectangle and side of square
function solve ( M , N , s ) { if ( N % s == 0 ) { N = N / s ; } else { N = ( N / s ) + 1 ; } if ( M % s == 0 ) { M = M / s ; } else { M = ( M / s ) + 1 ; } return parseInt ( M * N ) ; } var N = 12 , M = 13 , s = 4 ; document . write ( solve ( M , N , s ) ) ;