ProgrammingHard

What is gcd(84, 36) by the Euclidean algorithm?

  1. A. 6
  2. B. 12
  3. C. 4
  4. D. 3

Correct answer: B. 12

Euclid replaces (a, b) by (b, a mod b): (84, 36) -> (36, 12) -> (12, 0), so the gcd is 12. 6, 4 and 3 are common divisors but not the greatest.

More C Programming questions

Exams that ask this topic