ProgrammingHardTCS NQT · Infosys
What is gcd(48, 180) by Euclid's recursion?
- A. 6
- B. 12
- C. 24
- D. 4
Correct answer: B. 12
180 mod 48 = 36, 48 mod 36 = 12 and 36 mod 12 = 0, so the gcd is 12. Each step replaces the pair with (b, a mod b).
More C Programming questions
- What is lcm(12, 18)?
- unsigned int u = 3; int s = -4; printf("%d", (int)u + s); What is printed?
- How many leading zero bits does the 16-bit unsigned value 0x0100 have?
- What is the popcount of (1ULL << 40) | (1ULL << 3)?
- c is a char holding '5'. What is printf("%d", (c - '0') 2)?
- How many 1 bits does 0b10101 have?