I am stuck at this coding...the method should return the Greatest
Common Divisor (GCD) of two positive integers....For example the GCD
of 6 and 25 is 1....the GCD of 8 and 12 is 4....

The method I get from below is always a 1..


 public static int GCD(int x, int y)
       {

            if(x==0)
            {
                return y;

            }
            else if (y == 0)
            {
                return x;

            }



            else if ( y==1)
            {

                return 1;


            }

            else
            {
                return  GCD(x, (y - 1));



            }



        }

Reply via email to