ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

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

Correct answer: B. 5 2 0

gcd(0, n) is |n|. math.gcd returns a nonnegative result even for negative arguments, so gcd(-4, 6) is 2. gcd(0, 0) is 0.

More Python Programming questions

Exams that ask this topic