Pagini recente » Cod sursa (job #1140148) | Cod sursa (job #2740110) | Cod sursa (job #64276) | Cod sursa (job #823953) | Cod sursa (job #2544393)
import java.util.Scanner;
import java.io.File;
import java.io.PrintWriter;
public class Main {
public static void main (String[] args) {
try {
Scanner sc = new Scanner(new File("euclid2.in"));
int t = sc.nextInt();
PrintWriter pw = new PrintWriter("euclid2.out");
for (int i = 0; i < t; i++) {
pw.write(GCD(sc.nextInt(), sc.nextInt()) + "\n");
}
sc.close();
pw.close();
}
catch(Exception e) { }
}
private static long GCD(long a, long b) {
if (b == 0) return a;
return GCD(b, a % b);
}
}