ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
import math
print(math.gcd(0, -6), math.lcm(4, 6), -7 % -3, math.lcm(0, 5))
  1. A. 6 12 -2 0
  2. B. 6 12 1 5
  3. C. -6 12 -3 0
  4. D. 6 12 -1 0

Correct answer: D. 6 12 -1 0

gcd is always non-negative, so gcd(0, -6) is 6. The result of % takes the sign of the divisor, so -7 % -3 is -1, and lcm with 0 is 0.

More Python Programming questions

Exams that ask this topic