fork download
  1. import java.io.*;
  2. import java.util.Scanner;
  3.  
  4. class GCD {
  5. public static int gcd(int a,int b) {
  6. while (b !=0) {
  7. int tmp = a%b;
  8. a = b;
  9. b = tmp;
  10. }
  11. return a;
  12. }
  13. }
  14.  
  15. class Main {
  16. public static void main (String[] args) throws java.lang.Exception {
  17. Scanner in = new Scanner(System.in);
  18. int t = in.nextInt();
  19. int b = in.nextInt();
  20. for (int i=2; i<=t; ++i) {
  21. int a = in.nextInt();
  22. b = GCD.gcd (a, b);
  23. }
  24. System.out.print(b);
  25. }
  26. }
Success #stdin #stdout 0.06s 2184192KB
stdin
2
15 25
stdout
5