#include <iostream>
using namespace std;
int divideToSquare(int length,int width){
if(length<width||length<=0||width<=0){
cout<<"please check your input"<<endl;
return -1;
}
if (length%width == 0){
return width;
}
int smallWidth = length%width;
return divideToSquare(width,smallWidth);
}
int main() {
int length;
int width;
while(true){
cout<<"please enter length of rectangle:";
cin>>length;
cout<<"please enter width of rectangle:";
cin>>width;
if(length<=0||width<=0){
break;
}
cout<<"the width of square is"<<divideToSquare(length,width)<<endl;
}
}