Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The GCD (greatest common divisor) and LCM (least common multiple) of two numbers that your codes from the user. GCD is the largest number

  •  

The GCD (greatest common divisor) and LCM (least common multiple) of two numbers that your codes from the user. GCD is the largest number that both are divisible by and LCM is the smallest number that is the multiple of two numbers. For instance, GCD(18,42) is 6 because the largest number that both 18 and 42 are divisible by is 6. The LCM of 18 and 42 is 126. Write a program that asks the user for two numbers and computes their GCD. Shown below is a way to compute the GCD, called Euclid's Algorithm. First compute the remainder of dividing the larger number by the smaller number Next, replace the larger number with the smaller number and the smaller number with the remainder. Repeat this process until the smaller number is 0. The GCD is the last value of the larger number. In order to find the LCM of the two given numbers, start with the largest number and increase the numbers by one until you find a number, which is divisible by the both given numbers. NOTE: If the user enters two float numbers, the code should issue an error message. For example, if a 5. and b=2., then the output from the program should be: Enter the first integer number: 5 Enter the second integer number: 2 The Greatest Common Divider is: 1 The Larger Common Multiplier is: 10 Programmed by Stew Dent. Date: Sun Sept 5 21:05:41 2021 End of processing. If a 6.4, and b=4, then the output from the program should be: Enter the first integer number: 6.4 Enter the second integer number: 4 A float value is entered which is not acceptable! Programmed by Stew Dent. Date: Sun Sept 5 21:07:31 2021 End of processing.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Auditing and Assurance services an integrated approach

Authors: Alvin a. arens, Randal j. elder, Mark s. Beasley

14th Edition

133081605, 132575957, 9780133081602, 978-0132575959

More Books

Students also viewed these Programming questions

Question

Find reactions of support 1,2 and 3 F=10KN, a=2m, ?a=60 (45%) F 2a

Answered: 1 week ago

Question

=+46. Monthly gas prices, part 3. Using the data from Exercise

Answered: 1 week ago