GCD
class GCD{ public static void main(String ar[]){ int x=gcd(12,16); System.out.println("gcd = "+x); } static int gcd(int a,int b) { if (a>=b&&a%b==0) return(b); else if(a<b) return(gcd(b,a)); else return(gcd(b,a%b)); } }
Comments