ProgrammingHard
How many integers from 1 to 100 are divisible by 6 or by 9?
- A. 22
- B. 27
- C. 17
- D. 11
Correct answer: A. 22
There are 16 multiples of 6, 11 of 9 and 5 of 18. Inclusion-exclusion gives 16 + 11 - 5 = 22.
More C Programming questions
- With 32-bit unsigned int, what is 65536u 65536u?
- Exponentiation by squaring computes x^1000 with how many multiplications at most, counting squarings and the result multiplications?
- In ASCII, what is 'k' ^ 32 as a character?
- In a 32-bit unsigned int, what is (~0u) >> 28?
- What value does a[i] ^= a[j] leave when i and j refer to the same element?
- Which expression sets bit 31 of an unsigned 32-bit variable x with no undefined behaviour?