def isPrime(number):
if number > 1:
# Iterate from 2 to n / 2
for i in range(2, number):
# If num is divisible by any number between
# 2 and n / 2, it is not prime
if (number % i) == 0:
return False
else:
return True
else:
return False
if __name__=="__main__":
count=0
for i in range(2,5000):
#Checking if i is Prime or not using isPrime()
if isPrime(i):
count+=1
print("Total number of primes between 1 and 5000 is",count)
Get Answers For Free
Most questions answered within 1 hours.