Minimum squares to evenly cut a rectangle | CPP 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countRectangles ( int l , int w ) { int squareSide = __gcd ( l , w ) ; return ( l * w ) / ( squareSide * squareSide ) ; } int main ( ) { int l = 4 , w = 6 ; cout << countRectangles ( l , w ) << endl ; return 0 ; }