package Current.basic; /* * BasicMath.java * * Created on October 28, 2005, 11:05 AM */ /** * This class contains some static functions that do some basic mathematics. * * @author pat */ public final class BasicMath { /** gcd of two integers */ public static int gcd(int a, int b){ while (true){ if (b==0) return a; a=a%b; if (a==0) return b; b=b%a; } } /** gcd of all the integers in an array */ public static int gcd(int[] x){ if (x.length==1) return x[0]; int g=gcd(x[0],x[1]); for (int i=2; i0) return 1; return 0; } }