Question: java not c++ 59 .pdf Lab Eero 1 w 1 Lab Exercise 1: Finding the Greatest Common Divisor Problem: Write a program that prompts the
59 .pdf Lab Eero 1 w 1 Lab Exercise 1: Finding the Greatest Common Divisor Problem: Write a program that prompts the user to enter two positive integers and finds their greatest common divisor. Solution: Suppose you enter two integers 4 and 2, their greatest common divisor is 2. Suppose you enter two integers 16 and 24, their greatest common divisor is 8. So, how do you find the greatest common divisor? Let the two input integers be ni and n2. You know number 1 is a common divisor, but it may not be the greatest commons divisor. So you can check whether k (for k = 2, 3, 4, and so on) is a common divisor for n1 and n2, until k is greater than ni or n2. 60 on the
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
