Hello Friends, In this blog, you'll learn Python Program to Find all Prime Numbers within a given Range.
This Program asks the user to input the starting point of range and ending point of range to print the prime number within the range.
Prime Number : A prime number can only be divided (without a remainder) by itself and 1.
# Write a program to find all prime numbers within a given range. print("Enter starting number of range for prime numbers: ") a = int(input()) print("Enter last number of range for prime numbers: ") b = int(input()) c = a - 1 while c < b: c = c + 1 f = 0 for i in range(2, c): if (c % i) == 0: f = 1 break if f == 0: print(c)