int D = int.Parse(Console.ReadLine());
for (int i = 0; i < D; i++)
{
string wejscie = Console.ReadLine();
string[] liczby = wejscie.Split(" ");
int a = int.Parse(liczby[0]);
int b = int.Parse(liczby[1]);
int r, r2;
int output = 0;
if (a == b)
{
output = a;
}
else if (a % b == 0)
{
output = a;
}
else if (b % a == 0)
{
output = b;
}
else if (a > b)
{
r = a % b;
do
{
r2 = r;
r = b % r;
} while (r > 0);
output = (a * b) / r2;
}
else if (a < b)
{
r = b % a;
do
{
r2 = r;
r = a % r;
} while (r > 0);
output = (a * b) / r2;
}
Console.WriteLine(output);
}
Trochę na około ale wszystko niby działa. Co jest nie tak? Z góry dzięki za zainteresowanie! 