Minimum squares to evenly cut a rectangle | Java 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
class GFG { static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } static int countRectangles ( int l , int w ) { int squareSide = __gcd ( l , w ) ; return ( l * w ) / ( squareSide * squareSide ) ; } public static void main ( String [ ] args ) { int l = 4 , w = 6 ; System . out . println ( countRectangles ( l , w ) ) ; } }