Minimum squares to evenly cut a rectangle | Python3 code 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
import math NEW_LINE def countRectangles ( l , w ) : NEW_LINE INDENT squareSide = math . gcd ( l , w ) NEW_LINE return ( l * w ) / ( squareSide * squareSide ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT l = 4 NEW_LINE w = 6 NEW_LINE ans = countRectangles ( l , w ) NEW_LINE print ( int ( ans ) ) NEW_LINE DEDENT