🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)?

  1. A.The two formulas give different answers for small numbers
  2. B.Dividing first keeps the intermediate value small, avoiding overflow
  3. C.Division is faster than multiplication
  4. 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 →