Minimum number of blocks required to form Hollow Rectangular Prism | Function to display output ; Function to return minimum no of layers required to form the hollow prism ; Function to calculate no of blocks required for each layer ; No of blocks required for each row ; Check for no of layers is minimum ; Length , width , height of each block ; Side of one wall ; height of each wall
function disp ( row_no , block ) { document . write ( row_no * block ) ; } function row ( ht , h ) { return ht / h ; } function calculate ( l , w , h , a , ht ) { let no_block = ( 4 * a ) / l ; let row_no ; if ( h < w ) row_no = row ( ht , w ) ; else row_no = row ( ht , h ) ; disp ( row_no , no_block ) ; } let l = 50 , w = 20 , h = 35 ; let a = 700 ; let ht = 140 ; calculate ( l , w , h , a , ht ) ;