Question

# An integer 'n' greater than 1 is prime if its only positive divisor is 1 or...

An integer 'n' greater than 1 is prime if its only positive divisor is 1 or itself. For example, 2, 3, 5, and 7 are prime numbers, but 4, 6, 8, and 9 are not. Write a python program that defines a function isPrime (number) with the following header: def isPrime (number): that checks whether a number is prime or not. Use that function in your main program to count the number of prime numbers that are less than 5000. Obviously, in your main () you need to write a loop and repeatedly test whether a new number is prime calling the isPrime function. If the number is prime, increase the count by 1. The count is 0 initially. When it reaches 5000, the loop terminates. The problem can be broken into the following tasks: In the main, for number = 2, 3, 4, 5, 6, ., 5000 test whether each number is prime using the function isPrime (number) that you will define If the number is prime increase the count by 1 Hint for your main (): use the following algorithm

*** IN PYTHON

``````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)``````

#### Earn Coins

Coins can be redeemed for fabulous gifts.