Data Structures & AlgorithmsModerateTCS NQT · SSC CGL Tier 2
Problem: The sum of the digits of 2^15 is what value?
- A. 25
- B. 26
- C. 22
- D. 5
Correct answer: B. 26
2¹⁵ = 32768 and 3 + 2 + 7 + 6 + 8 = 26. 2¹⁶ = 65536 gives 25, 2¹⁴ = 16384 gives 22, and 2⁵ = 32 gives 5.
More Coding Interview Problems questions
- Problem: How many subarrays of [2, 4, 1, 3, 6, 5] have an even sum? Run the code. python a = [2, 4, 1, 3, 6, 5] print(sum(1 for i in…
- Problem: How many integers x in [1, 999] satisfy x ≡ 2 (mod 3) and x ≡ 5 (mod 7)? Run the code. python print(sum(1 for x in range(1, 1000)…
- Problem: How many squares (k k with k >= 1) are at most 10^6? Run the code. python print(sum(1 for k in range(1, 10 6) if k k <= 10 6))…
- Problem: What is the maximum value of x (100 - x) over integers 0 <= x <= 100? Run the code. python print(max(x (100 - x) for x in…
- Problem: What is the number of trailing zeros in 100! expressed in base 6 (count of factors of 6)? Run the code. python n = 100 c2 = c3 =…
- Problem: How many ways can you pick 2 different integers from [1, 20] whose sum is divisible by 4? Run the code. python print(sum(1 for i…