ProgrammingVery hardTCS NQT · Accenture

What is printed?

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

Correct answer: B. 5 2 0 12

gcd ignores signs, and gcd(0, n) is the absolute value of n. The lcm of 0 and any number is 0, and lcm(-4, 6) is 12 because the sign is ignored.

More Python Programming questions

Exams that ask this topic