Programming-for-Output-Problems
October 6, 2023Programming-for-Output-Problems
October 6, 2023Programming-for-Output-Problems
Question 31
|
Assume A and B are non zero positive integers. The following code segment
Computes the LCM of two numbers
|
|
Divides the larger number by the smaller number
|
|
Computes the GCD of two numbers
|
|
Finds the smaller of two numbers
|
Question 31 Explanation:
→ The above iterative code is computes the GCD of two numbers using euclidean algorithm.
→ The procedure is to subtract smaller number from larger. So that we can reduce larger number then doesn’t change the value of GCD.
→ if we performing number of iterations based on condition the larger of two numbers will end up with GCD.
→ The procedure is to subtract smaller number from larger. So that we can reduce larger number then doesn’t change the value of GCD.
→ if we performing number of iterations based on condition the larger of two numbers will end up with GCD.
Correct Answer: C
Question 31 Explanation:
→ The above iterative code is computes the GCD of two numbers using euclidean algorithm.
→ The procedure is to subtract smaller number from larger. So that we can reduce larger number then doesn’t change the value of GCD.
→ if we performing number of iterations based on condition the larger of two numbers will end up with GCD.
→ The procedure is to subtract smaller number from larger. So that we can reduce larger number then doesn’t change the value of GCD.
→ if we performing number of iterations based on condition the larger of two numbers will end up with GCD.
Subscribe
Login
0 Comments