Here you can find the source of gcd(int a, int b)
public static int gcd(int a, int b)
//package com.java2s; /**/* ww w . jav a2 s . co m*/ * This class is part of JCodec ( www.jcodec.org ) This software is distributed * under FreeBSD License * * @author The JCodec project * */ public class Main { public static int gcd(int a, int b) { if (b != 0) return gcd(b, a % b); else return a; } public static long gcd(long a, long b) { if (b != 0) return gcd(b, a % b); else return a; } }