Minimum number of Cuboids required to form a Cube | Function to calculate and return LCM of a , b , and c ; Find GCD of a and b ; Find LCM of a and b ; LCM ( a , b , c ) = LCM ( LCM ( a , b ) , c ) ; Finding LCM of a , b , c ; return LCM ( a , b , c ) ; Function to find the minimum number of cuboids required to make the volume of a valid cube ; Find the LCM of L , B , H ; Volume of the cube ; Volume of the cuboid ; Minimum number cuboids required to form a cube ; Driver Code ; Given dimensions of cuboid ; Function Call
def find_lcm ( a , b , c ) : NEW_LINE INDENT g = __gcd ( a , b ) ; NEW_LINE LCM1 = ( a * b ) // g ; NEW_LINE g = __gcd ( LCM1 , c ) ; NEW_LINE LCM = ( LCM1 * c ) // g ; NEW_LINE return LCM ; NEW_LINE DEDENT def minimumCuboids ( L , B , H ) : NEW_LINE INDENT lcm = find_lcm ( L , B , H ) ; NEW_LINE volume_cube = lcm * lcm * lcm ; NEW_LINE volume_cuboid = L * B * H ; NEW_LINE print ( ( volume_cube // volume_cuboid ) ) ; NEW_LINE DEDENT def __gcd ( a , b ) : NEW_LINE INDENT if ( b == 0 ) : NEW_LINE INDENT return a ; NEW_LINE DEDENT else : NEW_LINE INDENT return __gcd ( b , a % b ) ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT L = 1 ; B = 1 ; H = 2 ; NEW_LINE minimumCuboids ( L , B , H ) ; NEW_LINE DEDENT