#include <iostream>
using namespace std;
int divideToSquare(int length, int width) {
int nextWidth = 0;
if (length > width) {
nextWidth = length % width;
length = width;
width = nextWidth;
}
else {
nextWidth = width % length;
width = nextWidth;
}
if (width == 0) {
return length;
}
else {
return divideToSquare(length, width);
}
}
int main() {
cout << "The width of square for rectangle(1680, 640) is " << divideToSquare(1680, 640) << endl;
cout << "The width of square for rectangle(640, 1680) is " << divideToSquare(640, 1680) << endl;
cout << "The width of square for rectangle(640, 1680) is " << divideToSquare(80, 40) << endl;
cout << "The width of square for rectangle(640, 1680) is " << divideToSquare(18, 3) << endl;
return 0;
}