Recursion Worksheet


     public static int GCD(int A, int B) {
        if (A % B == 0)
           return B;
        else
           return GCD(B, A % B);
     }
  1. Trace the following call to GCD, and tell what is returned:
         GCD(385,120);
    
  2. Trace the following call to GCD, and tell what is returned:
         GCD(126,238);
    
  3. What happens if B > A?

Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2008