ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
from functools import reduce
import math
print(reduce(math.gcd, [12, 18, 24]), reduce(math.lcm, [4, 6, 10]))
  1. A. 6 120
  2. B. 2 60
  3. C. 12 60
  4. D. 6 60

Correct answer: D. 6 60

gcd(12, 18) = 6 and gcd(6, 24) = 6. lcm(4, 6) = 12, and lcm(12, 10) = 60.

More Python Programming questions

Exams that ask this topic