The GCD (greatest common divisor) and LCM (least common multiple) of two numbers that your codes...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Related Book For
Auditing and Assurance services an integrated approach
ISBN: 978-0132575959
14th Edition
Authors: Alvin a. arens, Randal j. elder, Mark s. Beasley
Posted Date:
Students also viewed these programming questions
-
Exercise 8-1 (Algo) Perpetual inventory system; journal entries [LO8-1] Specialty Store uses a perpetual Inventory system. The following are some Inventory transactions for the month of May: 1....
-
a. Write a program that asks the user to enter a password. If the user enters the right password, the program should tell them they are logged in to the system. Otherwise, the program should ask them...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Find reactions of support 1,2 and 3 F=10KN, a=2m, ?a=60 (45%) F 2a
-
Why does the message receivers culture affect the choice of direct or indirect plan for communicating negative messages?
-
Thirty GPAs from a randomly selected sample of statistics students at Oxnard College are available at this text's website. Assume that the population distribution is approximately Normal. The...
-
Midwest Industrial Products Corporation makes two products, Product H and Product L. Product H is expected to sell 50,000 units next year and Product L is expected to sell 10,000 units. A unit of...
-
Hugh Colson deposited $20,000 in a special savings account that provides for interest at the annual rate of 12% compounded semiannually if the deposit is maintained for four years. Required Calculate...
-
Carefully graph the two problems below. Use a different color for each section of the graph. Identify whether or not the graph is a function. Then, evaluate the graph at any specified domain values....
-
The balance sheets of E Ltd. and J Ltd. on December 30, Year 6, were as follows: Plant assets (net) Cash and receivables Inventory Intangible assets E Ltd. $ 96,400 J Ltd. $ 57,800 229,600 24,400...
-
Diversity can involve which of the following? a. Gender b. Race c. Age d. All of these
-
Diversity is considered an important element of the modern workplace; however, there is little practical benefit to be gained by actively promoting it. a. True b. False
-
Ethical behaviour is not as profitable as unethical behaviour, but it has other advantages. a. True b. False
-
Employment in the service sector is expected to decline in the near future. a. True b. False
-
The switch to international financial reporting standards throughout the European Union was a considerable breakthrough towards the use of such standards on a worldwide basis. As this article...
-
The following set of data is from a sample of n=6. 9 2 1 9 10 13 a. Compute the mean, median, and mode. b. Compute the range, variance, standard deviation, and coefficient of variation. c. Compute...
-
Using the theoretical sampling strategy, how many samples of size 4 (n = 4) can be drawn from a population of size: (a) N = 5? (b) N = 8? (c) N = 16? (d) N = 50?
-
Assume that Casio Computer Company, LTD. sells handheld communication devices for \($150\) dur- ing August as a back-to-school special. The normal selling price is \($225\). The standard variable...
-
Following are ten unrelated situations that would ordinarily be expected to affect one or more standard cost variances: il. Dd, A salaried production supervisor is given a raise, but no adjustment is...
-
The following information pertains to the standard costs and actual activity for Repine Company for September: There were no beginning direct materials inventories. Required a. Determine the...
Study smarter with the SolutionInn App