Data Structures & AlgorithmsHardProduct Company SDE · CP practice
Problem: What is the smallest positive integer with exactly 10 positive divisors? Run the search.
Problem: What is the smallest positive integer with exactly 10 positive divisors? Run the search.
n = 1
while sum(1 for d in range(1, n + 1) if n % d == 0) != 10:
n += 1
print(n)What is printed?- A. 24
- B. 30
- C. 48
- D. 36
Correct answer: C. 48
Since 48 = 2^4 * 3 has divisor count 5 * 2 = 10, it is the smallest; 24, 30 and 36 have 8, 8 and 9 divisors.
More Coding Interview Problems questions
- Problem: How many integers n in [1, 100] reach 1 under the Collatz map within 10 steps? Run the code. python def steps(n): c = 0 while n…
- Problem: How many ordered pairs (a, b) with 1 <= a, b <= 30 have a^2 + b^2 a perfect square? Run the code. python print(sum(1 for a in…
- Problem: How many distinct strings can be formed by rearranging the letters of 'aabbc'? Run the code. python from itertools import…
- Problem: A 3-person committee is chosen from 6 people. How many committees include at least one of two specific people A or B? Run the…
- Problem: How many non-negative integer solutions (x, y, z) of x + y + z = 10 satisfy x <= 4? Run the code. python print(sum(1 for x in…
- Problem: How many pairs (x, y) with x <= y and x + y = 12 lie in 1..11? Run the code. python print(sum(1 for x in range(1, 12) for y in…