<?php
// F1 > F2
// F1 = F2
// F1 < F2
fscanf(STDIN, "%d", $N);
for ($i = 0;$i < $N;$i++) {
fscanf(STDIN, "%d %d", $F1, $F2);
if ($F2 == $F1) {
$mdc = $F1;
continue;
}
elseif ($F2 > $F1) {
$temp = $F2;
$F2 = $F1;
$F1 = $temp;
}
for($resto = 1;$resto > 0;){
if ($F1 > $F2) {
$resto = $F1 % $F2;
$F1 = $F2;
$F2 = $resto;
}
}
$mdc = $F1;
echo "{$mdc}\n";
}
?>
To embed this project on your website, copy the following code and paste it into your website's HTML: