Question

# How to code this in python Write a program that computes and prints the first 1000...

How to code this in python

Write a program that computes and prints the first 1000 prime numbers - simply write out each prime number on a new line. In implementing this solution I want you to define 2 functions: is_prime which can be used to test whether a number is a prime (e.g. is_prime(17) returns True but is_prime(9) returns False) and compute_primes which will return an array (or Python list) of the first n primes where n is passed as an argument (e.g. compute_primes(10) returns a list of the 1st 10 prime numbers). Note: you can check your answer here: https://primes.utm.edu/lists/small/1000.txt

In case of any doubt comment below. Please UPVOTE if you Liked the answer.

``````def isPrime(n):
if n <= 1:
return 0
for i in range(2, n):
if n % i == 0:
return 0;
return 1

def compute(n):
counter = 0
# first prime number

k = 2
while counter !=n:
if isPrime(k) == 1:
counter+=1
k+=1

print(i)``````

#### Earn Coins

Coins can be redeemed for fabulous gifts.