ProgrammingHard
What is gcd(84, 36) by the Euclidean algorithm?
- A. 6
- B. 12
- C. 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
- How many divisors does 10 have among 1 through 10?
- int c = 0; for (int i = 0; i < 7; i++) for (int j = 0; j < 7; j++) if (i == j) c++; printf("%d", c); What is printed?
- static int next = 1; int f(void) { return next = 2; } / f is called three times; what does the third call return? /
- struct In { int v; }; struct Out { struct In in; int k; }; struct Out o = {{7}, 2}; printf("%d", o.in.v + o.k); What is printed?
- int p = NULL; if (p && p == 3) puts("match"); else puts("no match"); What is printed?
- #define MAX(a, b) ((a) > (b) ? (a) : (b)) printf("%d", MAX(3, 2 + 2)); What is printed?