← Quiz: Number Programs in C: all 10 questions
Quiz: Number Programs in C · Question 8 of 10
Why is lcm = a / gcd(a, b) b better than a b / gcd(a, b)?
Why is lcm = a / gcd(a, b) * b better than a * b / gcd(a, b)?
- A.The two formulas give different answers for small numbers
- B.Dividing first keeps the intermediate value small, avoiding overflow
- C.Division is faster than multiplication
- D.It works for negative numbers only
Answer & explanation
Correct answer: Dividing first keeps the intermediate value small, avoiding overflow
a × b can exceed the int range even when the LCM itself fits.
Can you get the rest right without peeking?
Take the timed Quiz: Number Programs in C quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →