subject

Prime numbers (with the exception of 2) are always odd; so, aside from 2 and 3, the smallest possible difference between consecutive prime numbers is 2. For instance, 5 and 7 are primes, and 7 - 5 = 2; 11 and 13 are primes, and 13 - 11 = 2; 17 and 19 are primes, and 19 - 17 = 2; etc. Two primes that differ by 2 are called twin primes. It has been known since antiquity that there are infinitely many prime numbers; however, it is still unproven that there are infinitely many twin prime pairs. (That is, it is unproven that the list that starts with (3,5), (5,7), (11,13), (17,19), (29,31), (41,43), . . . never ends.) Interestingly, huge progress was made four years ago by an until-then-unfamous mathematician named Yiteng Zheng.

Your first mission is to create a function called is prime. This function should take a positive integer as input, and return True if it has exactly two factors, and False otherwise. In my twins. py file, I have kindly put some text code, so that you can see if your function is working properly - none of the lines should say ERROR!.

Once your function is working, delete my code. Your next mission is to create a program that asks the user to provide two positive integers P and Q. Your program should print all the twin prime pairs that lie between P and Q, inclusive. So, for example, if the user enters 11 and 43, the program should output (11,13), (17,19), (29,31). (41, 43). If the user enters 11 and 41, the program should just output (11,13), (17,19), (29, 31), since 43 isn't between 11 and 41.

The simplest way to do this is, roughly, go through the integers from P to Q: for each number, determine whether that number and that number plus 2 are both prime. Of course, it is up to you to get all the details right.

Specifications: your program must

1. write a function called is prime, which takes a positive integer, and returns the value True if the integer is prime, and False if the integer is not prime. (It only needs to work for positive integers, note that 1 is technically not prime!)
2. ask the user to enter in two positive integers, P and Q.
3. print out all pairs of twin primes where both the primes are between P and Q inclusive.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:30
Jasper and samantha are in a robotics competition. the guidelines state that the robots should be able to move a 10-gram weight at least 2 meters and turn in a circle. jasper and samantha have already built the robot. which step of the design process should they follow next to decide whether their robot meets the minimum criteria for the competition?
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
When creating a budget, log fixed expenses before income. after income. after savings. at the top.
Answers: 1
question
Computers and Technology, 22.06.2019 21:50
Answer the following questions regarding your system by using the commands listed in this chapter. for each question, write the command you used to obtain the answer. a. what are the total number of inodes in the root filesystem? how many are currently utilized? how many are available for use? b. what filesystems are currently mounted on your system? c. what filesystems are available to be mounted on your system? d. what filesystems will be automatically mounted at boot time?
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
Me dangers of social media and the internetexplain what each means: 1) social media and phones have become an addiction.2) outside people have access to you all the time.3) cyberstalking4) cyberbullying5) catphishing6) viruses7) identity theft8) credit card fraud9) hacking10) money schemes
Answers: 1
You know the right answer?
Prime numbers (with the exception of 2) are always odd; so, aside from 2 and 3, the smallest possibl...
Questions
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
English, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
question
Biology, 13.09.2020 02:01
question
Mathematics, 13.09.2020 02:01
Questions on the website: 13722363