Data Structures & AlgorithmsModerateSSC CGL Tier 2 · TCS NQT
Problem: How many prime numbers lie strictly between 100 and 150?
- A. 12
- B. 35
- C. 25
- D. 10
Correct answer: D. 10
101, 103, 107, 109, 113, 127, 131, 137, 139, 149: ten primes. Sieving only by 2, 3, 5, 7 lets 121 and 143 through for 12, 35 counts primes up to 150, and 25 counts primes up to 100.
More Coding Interview Problems questions
- Problem: The number of decimal digits in 100! is what value?
- Problem: What is gcd(462, 1071)?
- Problem: What is the determinant of the matrix [[2, 1], [1, 3]]?
- Problem: How many permutations of the letters A, B, C, D leave no letter in its original position (for example, A is not in the first…
- Problem: The sum of all integers from 1 to 200 that are divisible by neither 4 nor 7 is what value?
- Problem: How many integers from 1 to 100 inclusive are divisible by 7 but not by 14?