Data Structures & AlgorithmsModerateTCS NQT · number puzzle
Problem: What is the smallest positive integer whose decimal digits multiply to 36? Run the search code.
Problem: What is the smallest positive integer whose decimal digits multiply to 36? Run the search code.
x = 1
while True:
p = 1
for ch in str(x):
p *= int(ch)
if p == 36:
break
x += 1
print(x)What is printed?- A. 49
- B. 66
- C. 94
- D. 36
Correct answer: A. 49
Digits 4 and 9 multiply to 36. Two-digit numbers below 49 have digit products other than 36, so 49 is the smallest.
More Coding Interview Problems questions
- Problem: How many ways are there to place 2 non-attacking rooks on a 3 x 3 board (distinct squares, different rows and different columns…
- Problem: How many monotone lattice paths from (0,0) to (2,2) exist on a 3 x 3 grid if the moves are right, down or diagonal (down-right)?…
- Problem: What is the sum of i (5 - i) for i from 1 to 4? Run the code. python print(sum(i (5 - i) for i in range(1, 5))) What is printed?
- Problem: What is the sum of gcd(i, j) over all pairs 1 <= i < j <= 4? Run the code. python from math import gcd print(sum(gcd(i, j) for i…
- Problem: What is the digit sum of 2^100? Run the code. python print(sum(int(c) for c in str(2 100))) What is printed?
- Problem: How many triples (a, b, c) with 1 <= a <= b <= c <= 10 have a + b + c = 12? Run the code. python print(sum(1 for a in range(1…