Minimum squares to evenly cut a rectangle | PHP program to find minimum number of squares to make a given rectangle . ; if we take gcd ( l , w ) , this will be largest possible side for square , hence minimum number of square . ; Number of squares . ; Driver code
< ? php function gcd ( $ a , $ b ) { return $ b ? gcd ( $ b , $ a % $ b ) : $ a ; } function countRectangles ( $ l , $ w ) { $ squareSide = gcd ( $ l , $ w ) ; return ( $ l * $ w ) / ( $ squareSide * $ squareSide ) ; } $ l = 4 ; $ w = 6 ; echo countRectangles ( $ l , $ w ) . " STRNEWLINE " ; ? >