Here you can find the source of gcd(int a, int b, int... rest)
public static int gcd(int a, int b, int... rest)
//package com.java2s; //License from project: Apache License public class Main { public static int gcd(int a, int b, int... rest) { if (rest.length > 0) { int[] rest1 = new int[rest.length - 1]; System.arraycopy(rest, 1, rest1, 0, rest1.length); return gcd(gcd(a, b), rest[0], rest1); }/*www. j a v a2s . c o m*/ return b == 0 ? a : gcd(b, a % b); } }