Data Structures & AlgorithmsModerateProduct Company SDE · CP practice
Problem: What is the sum of the digits of the number 2^64? Run the code.
Problem: What is the sum of the digits of the number 2^64? Run the code.
print(sum(int(c) for c in str(2 ** 64)))What is printed?
- A. 87
- B. 88
- C. 20
- D. 65
Correct answer: B. 88
2⁶⁴ = 18446744073709551616, whose digits sum to 88. 2⁶⁴ − 1 (the uint64 maximum) gives 87, 20 is the number of digits, and 65 is the bit length.
More Coding Interview Problems questions
- Problem: How many integers x in [1, 2000] satisfy x^2 ≡ x (mod 10)? Run the code. python print(sum(1 for x in range(1, 2001) if (x x - x)…
- Problem: How many inversions does the array [2, 3, 8, 6, 1] have? Run the code. python a = [2, 3, 8, 6, 1] print(sum(1 for i in…
- Problem: What is the number of distinct subarray sums of [1, 2, 3] (non-empty subarrays)? Run the code. python a = [1, 2, 3]…
- Problem: What is the sum of all two-digit numbers that are divisible by the sum of their digits? Run the code. python print(sum(x for x in…
- Problem: How many integers in [1, 1000] are both perfect squares and perfect cubes? Run the code. python print(sum(1 for x in range(1…
- Problem: How many integers in [1, 100] are divisible by neither 2 nor 3? Run the code. python print(sum(1 for x in range(1, 101) if x % 2…