Paper Cut into Minimum Number of Squares | Java program to find minimum number of squares to cut a paper . ; To swap two numbers ; 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
class GFG { static void swap ( int a , int b ) { int temp = a ; a = b ; b = temp ; } static int minimumSquare ( int a , int b ) { int result = 0 , rem = 0 ; if ( a < b ) swap ( a , b ) ; while ( b > 0 ) { result += a / b ; rem = a % b ; a = b ; b = rem ; } return result ; } public static void main ( String [ ] args ) { int n = 13 , m = 29 ; System . out . println ( minimumSquare ( n , m ) ) ; } }