by Dinesh Thakur Category: Java Methods



class CommonDivisor
            int gcd(int m, int n)
                        int r;
                        if (m < n) return gcd(n,m);
                        r = m%n;
                        if (r == 0) return(n);
                        else return(gcd(n,r));
                        public static void main(String args[]) throws IOException
                        CommonDivisor Divisor = new CommonDivisor();
                 BufferedReader BuffRead = new BufferedReader(new InputStreamReader(;
                        String Num;
                        int a,b,Div;
                        System.out.print("Enter a Number :");
                        System.out.print("Enter Another Number :");
                        System.out.print("The Greatest Common Divisor is "+Div);

Greatest Common Divisor Using Recursion

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.