Here you can find the source of gcd(long a, long b)
public static long gcd(long a, long b)
//package com.java2s; public class Main { public static long gcd(long a, long b) { long r = a; a = Math.max(a, b);/*from w w w . j av a2 s. c om*/ b = Math.min(r, b); r = b; while (a % b != 0) { r = a % b; a = b; b = r; } return r; } public static int gcd(int a, int b) { return (int) gcd((long) a, (long) b); } public static short gcd(short a, short b) { return (short) gcd((long) a, (long) b); } public static byte gcd(byte a, byte b) { return (byte) gcd((long) a, (long) b); } public static float max(float... fs) { float max = 0; if (fs.length > 0) { max = fs[0]; for (float f : fs) { if (f > max) { max = f; } } } return max; } public static double max(double... ds) { double max = 0; if (ds.length > 0) { max = ds[0]; for (double d : ds) { if (d > max) { max = d; } } } return max; } }