Ask Question

Produce a list named primes which only contains the central number of two twin primes in the range [2,1000]. (A twin prime is a prime number which has another prime number two away from it, like 41 and 43; in this case, we would add the number 42 to our list.) We provide a function is_prime to assist you with this. Call it like this: is_prime (5).

+1
Answers (1)
  1. 16 August, 11:04
    0
    def is_prime (x):

    for i in range (2, x):

    if x%i==0:

    return False

    return True

    primes=[]

    for i in range (2,1001):

    # print (i, is_prime (i), is_prime (i+2))

    if is_prime (i) and is_prime (i+2):

    primes. append (i+1)

    print (primes)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Produce a list named primes which only contains the central number of two twin primes in the range [2,1000]. (A twin prime is a prime ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers