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
-
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
-
Describe a circumstance that would require a businessperson to transmit an unsolicited negative message. For this circumstance, explain the plan of organization that you would use and justify your...
-
Menezes Company had the following transactions in March: (a) Materials were purchased on account, $40,000. (b) Materials were requisitioned: $33,000 for production and $2,000 for indirect factory...
-
The temperature and pressure of air are \(30^{\circ} \mathrm{C}\) and \(1 \mathrm{~atm}\) respectively. The mass of air behaving ideally contained in a room of size \(5 \mathrm{~m} \times 5...
-
Lenows Drug Stores and Halls Pharmaceuticals are competitors in the discount drug chain store business. The separate capital structures for Lenow and Hall are presented next. a. Compute earnings per...
-
Barnwell Corp. purchased fifteen $1,000 6% bonds of Voltgo Corporation when the market rate of interest was 8%. Interest is paid semiannually, and the bonds will mature in eight years. Using the PV...
-
Utility function is u(x.x) =x^2y and a consumer has |= $300 budget and he has preferences on media service provider such as Amazon, Netflix, x, and the composite good, denoted as y. Assume that Py-$1...
-
The auditor begins by reviewing the contracts ABC Construction has entered into. This involves understanding the terms, conditions, and specifications outlined in the agreements. Progress Billing...
-
In the opening story by John Hendricks, how much money did he pay the DJ to continuously play "Salt Peanuts", the first Be Bop record Hendricks ever heard?
-
Newgrowth is a high-tech company, whose earnings and dividends have grown by 30% per year since the firm's founding 10 years ago. Current stock price is 100, and next year's dividend is projected to...
-
Shane, a self-employed junior partner in a law firm, makes the following gifts with their values noted: 4 clients ($40 each) 10 clients ($20 each) What amount of the gifts is deductible?
-
Find an equation for a polynomial f with the given characteristics. A quartic polynomial function f with f ( 1 ) = 4 , f ' ( 1 ) = 0 , f ' ' ( 1 ) = - 3 6 , and f ' ' ' ' ( 1 ) = - 7 2
-
What is the difference between culture relativism and ethical subjectivism? Why are both theories inconsistent with ethical objectivism?
-
When you weigh yourself on good old terra firma (solid ground), your weight is 142 lb. In an elevator your apparent weight is 121 lb. What are the direction and magnitude of the elevator's...
-
How do you use functional requirements for this chapter?
-
How do you apply nonfunctional requirements for this chapter?
-
Identify the EBT for the word deployment.
Study smarter with the SolutionInn App