Program to display the prime number in a given range.
Let's create a program to display the prime numbers in a given range:
low = int(input("Enter lower range: ")) high = int(input("Enter upper range: ")) for n in range(low,high + 1): if n > 1: for i in range(2,n): if (n % i) == 0: break else: print(n)
Output:
Enter lower range: 5
Enter upper range: 50
5
7
11
13
17
19
23
29
31
37
41
43
47
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Let's create a program to display the prime numbers in a given range:
Output:
Enter lower range: 5
Enter upper range: 50
5
7
11
13
17
19
23
29
31
37
41
43
47
need an explanation for this answer? contact us directly to get an explanation for this answer