Question DSA-MATH-0007
EasyWhat is the output of this code?
import math
print(math.gcd(24, 18))
- A.
3
- B.
12
- C.
Show answer and explanation
Answer: D
math.gcd returns the greatest common divisor: 24 = 2³ × 3 and 18 = 2 × 3², so gcd = 2 × 3 = 6.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Math and Number Theory question
What is the output of this code?
import math
print(math.gcd(24, 18))
3
12
Answer: D
math.gcd returns the greatest common divisor: 24 = 2³ × 3 and 18 = 2 × 3², so gcd = 2 × 3 = 6.
36
6