93.7k views
3 votes
Write a program to print the prime numbers from 500 to 700. The program should also print the count of prime numbers between 500 and 700. A number is called a prime number if it has exactly two positive divisors, 1 and the number itself. For example, the number 5 is prime as it has only two divisors: 1 and 5.

1 Answer

6 votes

primes = 0

for x in range(500, 701):

count = 1

for w in range(2, x+1):

if x % w == 0:

count += 1

if count < 3:

print(x, end=" ")

primes += 1

print("\\There are {} prime numbers between 500 and 700".format(primes))

I hope this helps!

User Xorty
by
7.7k points