Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING PYTHON PROGRAMMIMG LANGUAGE 2) twins.py Prime numbers (with the exception of 2) are always odd; so, aside from 2 and 3, the smallest possible

USING PYTHON PROGRAMMIMG LANGUAGE

image text in transcribed

2) twins.py 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 an 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 test 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, foir 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 write a function called is-prime, which takes in an 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!) ask the user to enter in two positive integers, P and Q print out all pairs of twin primes where both the primes are between P and Q inclusive. Challenge (optional): read this article https://uww.nature.comews/peculiar-pattern-found-in-random-prime-numbers-1.19550. The second section, Not so random, describes a surprising recent observation about the last digits of consecutive primes. Write a program that will confirm these observations - only look at the primes less than 10,000,000

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

Does your message use dishonest or misleading language?

Answered: 1 week ago

Question

LO2 Discuss important legal areas regarding safety and health.

Answered: 1 week ago