Paper Cut into Minimum Number of Squares | C ++ program to find minimum number of squares to cut a paper . ; 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; int minimumSquare ( int a , int b ) { long long result = 0 , rem = 0 ; if ( a < b ) swap ( a , b ) ; while ( b > 0 ) { result += a / b ; long long rem = a % b ; a = b ; b = rem ; } return result ; } int main ( ) { int n = 13 , m = 29 ; cout << minimumSquare ( n , m ) ; return 0 ; }