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 23:50
List a few alternative options and input and output over the standerd keyboard and monitor. explain their functioning in details.
Answers: 2
question
Computers and Technology, 24.06.2019 00:00
Which tool could be used to display only rows containing presidents who served two terms
Answers: 3
question
Computers and Technology, 24.06.2019 07:00
Into what form does the barcode reader convert individual bar patterns?
Answers: 1
question
Computers and Technology, 24.06.2019 10:00
3. what do the terms multipotentialite, polymath, or scanner mean?
Answers: 2
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
History, 22.05.2020 04:09
question
Mathematics, 22.05.2020 04:09
question
History, 22.05.2020 04:09
question
Biology, 22.05.2020 04:09
Questions on the website: 13722361