ProgrammingHardTCS NQT · Infosys
What is lcm(12, 18)?
- A. 6
- B. 72
- C. 36
- D. 24
Correct answer: C. 36
lcm(a,b) = a / gcd(a,b) * b = 12 / 6 * 18 = 36. Dividing before multiplying keeps the intermediate value smaller.
More C Programming questions
- 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?
- A table of size 7 uses h(k) = k % 7 with linear probing. Keys 14, 21, 7 and 0 are inserted in that order. In which slot does key 0 land?