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 06:30
Exchanging which type of data uses the least bandwidth? music photographs video voice bandwidth- the amount of data that can be moved between two points in a set time period
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
Which location-sharing service offers items for users as a gaming component and also allows them to collectively link their check-ins to publish a trip? a. whrrl b. buzzd c. foursquare (this option is wrong i already tried) d. gowalla for plato
Answers: 2
question
Computers and Technology, 23.06.2019 09:00
Design a class tictactoe that: holds the following information about the game: two-dimensional array (3 by 3), and winner. add additional variables as needed. includes the functions to perform the various operations on objects. for example, function to print the board, getting the move, checking if move is valid, determining if there is a winner after each move. add additional operations as needed. includes constructor(s). write the functions of the class, and write a program that uses the class. the program should declare an object of type tictactoe. the program will create the board and store it in the array. the program will allow two players to play the tic-tac-toe game. after every valid move update the array, check if there is a winner. if there is no winner and no tie, then print the board again to continue.
Answers: 2
question
Computers and Technology, 23.06.2019 15:00
In the blank libreoffice writer document, to start the process of entering a date field into a letter, click on the insert menu. edit menu. file menu. fields menu.
Answers: 3
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, 24.11.2021 14:10
question
Mathematics, 24.11.2021 14:10
question
Computers and Technology, 24.11.2021 14:10
question
Mathematics, 24.11.2021 14:10
question
Mathematics, 24.11.2021 14:20
Questions on the website: 13722359