Data Structures & AlgorithmsHardProduct Company SDE · CP practice
Problem: What is the sum of all proper divisors of 220 (divisors smaller than 220)? Run the code.
Problem: What is the sum of all proper divisors of 220 (divisors smaller than 220)? Run the code.
print(sum(d for d in range(1, 220) if 220 % d == 0))What is printed?
- A. 504
- B. 18
- C. 284
- D. 11
Correct answer: C. 284
220 = 2² · 5 · 11; its proper divisors 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110 sum to 284, the amicable partner of 220. Including 220 itself gives σ(220) = 504, adding the distinct primes gives 18, and 11 counts the proper divisors.
More Coding Interview Problems questions
- Problem: What is the minimum number of coins from {1, 6, 10} that sum to 37? Run the DP. python INF = 10 9 d = [0] + [INF] 37 for v in…
- Problem: How many distinct arrangements of the letters of 'MISSISSIPPI' exist? Run the code. python import math print(math.factorial(11)…
- Problem: What is the maximum total of two non-overlapping subarrays of length 2 in [1, 5, 2, 8, 3]? Run the code. python a = [1, 5, 2, 8…
- Problem: How many integers in [1, 1000] have digit sum equal to 5 and are divisible by 5? Run the code. python print(sum(1 for x in…
- Problem: Which algorithm computes the number of shortest paths between all pairs in an unweighted graph in O(V E)?
- Problem: What is the time complexity of Kadane's algorithm extended to 2D (maximum-sum submatrix) with an n x n matrix?