Data Structures & AlgorithmsModerateTCS NQT · number theory
Problem: How many divisors does 720 have? Run the code.
Problem: How many divisors does 720 have? Run the code.
print(sum(1 for d in range(1, 721) if 720 % d == 0))What is printed?
- A. 30
- B. 24
- C. 36
- D. 28
Correct answer: A. 30
720 = 2^4 * 3^2 * 5, so the divisor count is 5 * 3 * 2 = 30.
More Coding Interview Problems questions
- Problem: How many ways are there to decode the digit string '111' (1 maps to A, ..., 26 maps to Z)? Run the DP. python s = '111' dp = [1]…
- Problem: What is the length of the longest substring without repeating characters in 'pwwkew'? Run the sliding-window code. python s =…
- Problem: How many distinct permutations (rearrangements as strings) of 'aabc' exist? Run the code. python from itertools import…
- Problem: What is the sum of C(10, k) over all even k from 0 to 10? Run the code. python from math import comb print(sum(comb(10, k) for k…
- Problem: How many integers in [100, 999] have all three digits distinct? Run the code. python print(sum(1 for x in range(100, 1000) if…
- Problem: What is the length of the longest strictly increasing contiguous run in [1, 3, 5, 4, 7, 8, 2]? Run the code. python a = [1, 3, 5…