Ask a Question

# This is the Question :- 1. You've to print all prime numbers between a range.
2. Take as input "low", the lower limit of range.
3. Take as input "high", the higher limit of range.
4. For the range print all the primes numbers between low and high (both included).
This is the code I write:- low = int(input())
high = int(input())
for i in range(low,high):
y = 0
x = int(i/2)
for j in range(2,x):
if i % j==0:
y = 1
break
if y == 0:
print(i)
Problem I faced in this is it take more time for the large number of range please help to shorten the time

This is the Question :- 1. You've to print all prime numbers between a range.
2. Take as input "low", the lower limit of range.
3. Take as input "high", the higher limit of range.
4. For the range print all the primes numbers between low and high (both included).
This is the code I write:- low = int(input())
high = int(input())
for i in range(low,high):
y = 0
x = int(i/2)
for j in range(2,x):
if i % j==0:
y = 1
break
if y == 0:
print(i)
Problem I faced in this is it take more time for the large number of range please help to shorten the time

Fuel your ambition, discover your passion and achieve your professional goals with LetsUpgrade.

Sign Up Now