Paper Cut into Minimum Number of Squares | Returns min number of squares needed ; swap if a is small size side . ; Iterate until small size side is greater then 0 ; Update result ; Driver code
function minimumSquare ( a , b ) { let result = 0 , rem = 0 ; if ( a < b ) { let temp = a ; a = b ; b = temp ; } while ( b > 0 ) { result += parseInt ( a / b ) ; let rem = a % b ; a = b ; b = rem ; } return result ; } let n = 13 , m = 29 ; document . write ( minimumSquare ( n , m ) ) ;