Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve this in python without the use of user defined functions. I know we can solve this with functions but it is not taught
Please solve this in python without the use of user defined functions. I know we can solve this with functions but it is not taught in the university yet and they will consider it as cheating if I use functions.
Thanks in advance.
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 rumber 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: 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 Jan 29 10:07:40 2023 End of processingStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started