HomeInterview QuestionsPrint all prime numbers between 100,000 and 191,00…

Print all prime numbers between 100,000 and 191,000.

🟡 Medium Coding Junior level
1Times asked
Jul 2026Last seen
Jul 2026First seen

💡 Model Answer

A straightforward way to list primes in a range is to test each number for divisibility up to its square root. The following Python script does that:

import math

def is_prime(n):

if n < 2:
    return False
if n % 2 == 0:
    return n == 2
r = int(math.isqrt(n))
for i in range(3, r + 1, 2):
    if n % i == 0:
        return False
return True

start, end = 100_001, 191_000

primes = [n for n in range(start, end + 1) if is_prime(n)]

print(primes)

The algorithm runs in O((end‑start) * sqrt(end)) time, which is acceptable for a range of ~90k numbers. For larger ranges a segmented Sieve of Eratosthenes would be more efficient, but for this size the simple trial division is clear and fast enough. The script prints a list of all primes between 100,001 and 191,000 inclusive.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500