Greatest Common Divisor Recursive Method Show all steps t

( Greatest Common Divisor - Recursive Method )

            Show all steps to use the pseudo - code segment below to find the return value of the following call to recursive function GCD() .          GCD(24, 56)

            FUNCTION GCD(parameter a, parameter b)

          IF (b == 0) THEN
             result a
          ELSE
             result GCD(b, a MOD b)

           END IF


          END FUNCTION

(1) Greatest Common Divisor Recursive Method Show all steps to use the pseudo Code segment below to find the return value of the following call to recursive function GCDO. GCD (24 56) FUNCTION GCD (parameter a parameter b) IF (b 0) THEN result a ELSE result GCD (b, a MOD b) END IF END FUNCTION

Solution

public class Divisor {

   public static void main(String[] args) {
       int a=24, b=56;
       System.out.println(\"GCD of 24, 56 = \"+GCD(a, b));
      
   }
  
  
   public static int GCD(int a, int b) {
       if(b==0)return a;
       else {
           a=a%b;
           return GCD(b, a);
       }
   }

}

( Greatest Common Divisor - Recursive Method ) Show all steps to use the pseudo - code segment below to find the return value of the following call to recursive

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site