1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kipiarov [429]
2 years ago
15

Write a program that prompts the user to enter two positive integers less than 1,000,000,000 and the program outputs the sum of

all the prime numbers between the two integers. Two prime numbers are called twin primes, if the difference between the two primes is 2 or -2. Have the program output all the twin primes and the number of twin primes between the two integers.
Computers and Technology
1 answer:
alexira [117]2 years ago
7 0

Answer:

In Python:

low = int(input("Low: "))

high = int(input("High: "))

if low >= 1000000000 or high >=1000000000:

   print("Out of range")

else:

   mylist = []

   for num in range(low,high+1):

       flag = False

       if num > 1:

           for i in range(2, num):

               if (num % i) == 0:

                   flag = True

                   break

       if not flag:

           mylist.append(num)

           print(num, end = " ")

   print()

   print("The twin primes are: ",end="")

   count = 0

   for i in range(1,len(mylist)):

       if mylist[i] - mylist[i-1] == 2:

           print(str(mylist[i])+" & "+str(mylist[i-1]),end=", ")

           count+=1

   print()

   print("There are "+str(count)+" twin primes")

Explanation:

See attachment for complete program where comments were used to explain each line

Download txt
You might be interested in
Types of Computer games​
kiruha [24]

\bold{Hello}~

\bold{Answer:}

<h3>Types of Computer games</h3>
  • Action
  • Adventure
  • Simulation
  • Sports
  • Role-playing
  • Puzzlers
  • Party games

<em>(</em><em>That's</em><em> </em><em>all</em><em> </em><em>i</em><em> </em><em>know</em><em>)</em><em> </em>

<h2>#Hopeithelps\:</h2>

\bold{-Kei}~

\tiny\sf\purple{ ♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡ }

5 0
2 years ago
The beginning statement of a loop is called a declaration.<br> True<br> False
Ilya [14]
It is true the reason why it is true is
4 0
2 years ago
Read 2 more answers
Plllzzzzzzzzzzzzzz annnssswweeweerrr...
s2008m [1.1K]

Answer:

An example of effective communication is when the person who you are talking to listens actively and absorbs your point and understands it.

Explanation:

Hope this helps!!

3 0
3 years ago
Who is the father of computer​
r-ruslan [8.4K]

charles babbage is the father of computer's

3 0
3 years ago
Read 2 more answers
Two electronics technicians are looking at the piece of testing equipment shown in the figure above. Technician A says that this
Ilya [14]
B is your correct answer.
8 0
3 years ago
Read 2 more answers
Other questions:
  • HELLLLLP ill make you brainiest and ill give u a lot of points if you HELP ME Directions Part One.
    12·2 answers
  • What is industry 4.0 -automation revolution-, what is your opinion about the direction this revolution is taking the industry in
    8·1 answer
  • Which of the following actions might contribute to recommendations you see online?
    6·1 answer
  • Spoken word and written word are different because what
    9·1 answer
  • Methods that require you to use an object to call them are called ____ methods.1. accessor
    7·1 answer
  • Disk ____ is the ability to spread data over multiple disks or volumes
    7·1 answer
  • The Company should use BLANK cables to provide Fast connectivity without electrical interference
    6·1 answer
  • __________ are hosted on dedicated computers known as 'web servers'.​
    8·2 answers
  • What is a best practice when approaching an automation effort?
    6·1 answer
  • Quick I need help ASAP
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!