Question: USING JAVA: - Create a code to calculate the greatest common divisor(GCD) for two positive integers entered by the user. The greatest common divisor of
USING JAVA:
- Create a code to calculate the greatest common divisor(GCD) for two positive integers entered by the user. The greatest common divisor of a number is the largest positive integer that divides each of the integers evenly. For example the GCD of 126 and 12 is 6. (6 x 2 = 12 & 6 x 21 = 126) or the GCD of 4 & 6 is 2. (2 x 2 = 4 & 2 x 3 = 6). These numbers need to be positive as well.
Follow these three steps while coding it:

Part 1 - Get positive number input: For our program to work correctly we need two positive integers. Code your program so that it asks for 2 integers. Then use sentinel while loops to make sure that the input we get is a positive number. Part 2 - Calculate the GCD: Assume our numbers are saved into x&y 1. Subtract x from y repeatedly until y
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
