Question

Find the GCD of 72 and 100 using the Euclidean GCD algorithm. In Java

Find the GCD of 72 and 100 using the Euclidean GCD algorithm.

In Java

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The answer to this question is as follows:

The code is as follows:

import java.util.*;
public class GCD
{

   public static int gcd_numbers(int value1, int value2)
   {
       if (value1 == 0)
           return value2;
      
       return gcd_numbers(value2%value1, value1);
   }

   public static void main(String[] args)
   {
       int value1 = 72, value2= 100;
       System.out.println("GCD of "+value1+" and "+value2+" is:"+gcd_numbers(value1, value2));

   }
}

The input and ouput is as follows:

✓ Execute Mode, Version, Inputs & Arguments JDK 11.0.4 Interactive Stdin Inputs Command Line Arguments Execute ... Result CPU

Add a comment
Know the answer?
Add Answer to:
Find the GCD of 72 and 100 using the Euclidean GCD algorithm. In Java
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT