Create and run a program that uses Euclid's algorithm to determine the greatest common divisor of two positive numbers. The greatest common divisor is defined as the biggest number that divides both values without leaving a remainder. Define a static function named gcd in the DivisorCalc class that takes two integers, num1 and num2. Make a driver to put your application through its paces. The iterative method is as follows: gcd (num1, num2) is num2 if num2 <= num1 and num2 evenly divides num1 gcd (num1, num2) is gcd(num2, num1) if num1 < num2 gcd (num1, num2) is gcd(num2, num1%num2) otherwise
Create and run a
gcd (num1, num2) is num2 if num2 <= num1 and num2
evenly divides num1
gcd (num1, num2) is gcd(num2, num1) if num1 < num2
gcd (num1, num2) is gcd(num2, num1%num2) otherwise
Create and run a program that uses Euclid's algorithm to determine the greatest common divisor of two positive numbers. The greatest common divisor is defined as the biggest number that divides both values without leaving a remainder. Define a static function named gcd in the DivisorCalc class that takes two integers, num1 and num2. Make a driver to put your application through its paces. The iterative method is as follows:
gcd (num1, num2) is num2 if num2 <= num1 and num2
evenly divides num1
gcd (num1, num2) is gcd(num2, num1) if num1 < num2
gcd (num1, num2) is gcd(num2, num1%num2) otherwise
Step by step
Solved in 2 steps with 1 images