Comprehensive and Detailed Explanation From Exact Extract:
The least common multiple (LCM) of two positive integers a and b is the smallest number that is a multiple of both. A function to compute the LCM requires a and b as inputs to perform the calculation (e.g., using the formula LCM(a, b) = (a * b) / GCD(a, b), where GCD is the greatest common divisor). According to foundational programming principles, the function’s inputs must include all values needed to compute the output.
Task Analysis:
Goal: Compute LCM of a and b.
Required inputs: The two integers a and b.
Output: The LCM (denoted as L in the question).
Option A: "L only." This is incorrect. L is the output (the LCM), not an input. The function needs a and b to calculate L.
Option B: "a * b." This is incorrect. The product a * b is used in the LCM formula (LCM = (a * b) / GCD(a, b)), but the function needs a and b separately to compute the GCD and then the LCM.
Option C: "a and L." This is incorrect. L is the output, not an input, and the function does not need L to compute itself.
Option D: "a and b." This is correct. The function requires the two integers a and b as inputs to compute their LCM. For example, in Python:
def lcm(a, b):
def gcd(x, y):
while y:
x, y = y, x % y
return x
return (a * b) // gcd(a, b)
Certiport Scripting and Programming Foundations Study Guide (Section on Functions and Parameters).
Cormen, T.H., et al., Introduction to Algorithms, 3rd Edition (Chapter 31: Number-Theoretic Algorithms).
GeeksforGeeks: “LCM of Two Numbers” (https://www.geeksforgeeks.org/lcm-of-two-numbers/).
Submit