Here you can find the source of gcd(int a, int b)
public static int gcd(int a, int b)
//package com.java2s; //License from project: Open Source License public class Main { public static int gcd(int a, int b) { while (b != 0) { int h = a % b; a = b;/*from w w w . j a v a 2 s .c o m*/ b = h; } return a; } }