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
Which of the following are examples of software? Check all of the boxes that apply.
dezoksy [38]

Hey!

------------------------------------------

<h3>Answers:</h3>

Operating System

Web Browser

Word Processor

Device Driver

------------------------------------------

<h3>Explanation:</h3>

Software is a set of data that tells the computer what to do. Each of the answer above tell the computer something specific to do.

The operating system are basic functions that make the computer run smoothly.

The web browser is telling the computer you want to look something up like in internet explorer, firefox, and chrome.

The word processor is a piece of software that tells the computer that you want to format a piece of text like in Microsoft word.

The device driver is a piece of software that controls a connected device like a phone or another computer.

------------------------------------------

Hope This Helped! Good Luck!

4 0
2 years ago
Read 2 more answers
The basic input/output system (bios locates the boot loader program on a linux system by reading the __________ on the hard driv
Diano4ka-milaya [45]
If the disk was formatted with fdisk, the MBR (Master Boot Record).
6 0
3 years ago
Many programmers today use a(n) _________, which is software that helps them build their computer programs. eula cad sdlc ide
kipiarov [429]
The answer is Integrated Development Environment (IDE). Many programmers today use Integrated Development Environment (IDE) which is a software that helps them build their computer programs. It gives complete facilities to computer programmers for software development.  
8 0
3 years ago
A general rule for adding text to a slide is ____.
Rama09 [41]

A general rule for adding text to a slide is to use not more than two fonts in a presentation and vary the font size. Furthermore, to make a slide legible, in addition to the point size, attention must be paid to the word count per slide, the choice of typeface, and the visual balance of  space to text.

4 0
3 years ago
Read 2 more answers
Sketch f(x) = 5x2 - 20 labelling any intercepts.​
Norma-Jean [14]

Answer:

  • The graph of the function is attached below.
  • The x-intercepts will be: (2, 0), (-2, 0)
  • The y-intercept will be: (-20, 0)

Explanation:

Given the function

f\left(x\right)\:=\:5x^2-\:20

As we know that the x-intercept(s) can be obtained by setting the value y=0

so

y=\:5x^2-\:20

switching sides

5x^2-20=0

Add 20 to both sides

5x^2-20+20=0+20

5x^2=20

Dividing both sides by 5

\frac{5x^2}{5}=\frac{20}{5}

x^2=4

\mathrm{For\:}x^2=f\left(a\right)\mathrm{\:the\:solutions\:are\:}x=\sqrt{f\left(a\right)},\:\:-\sqrt{f\left(a\right)}

x=\sqrt{4},\:x=-\sqrt{4}

x=2,\:x=-2

so the x-intercepts will be: (2, 0), (-2, 0)

we also know that the y-intercept(s) can obtained by setting the value x=0

so

y=\:5(0)^2-\:20

y=0-20

y=-20

so the y-intercept will be: (-20, 0)

From the attached figure, all the intercepts are labeled.

8 0
2 years ago
Other questions:
  • According to the ethical computer use policy, users should be __________ of the rules and, by agreeing to use the system on that
    11·1 answer
  • How is a correction made to an Electronic health record?
    14·1 answer
  • Write the definition of a function named averager that receives a double parameter and returns-- as a double -- the average valu
    11·1 answer
  • Community gardens are public gardens where local residents can grow plants in a plot. They are very popular, so there are often
    7·1 answer
  • This is 6th grade career class.
    10·1 answer
  • What is a header row?
    8·1 answer
  • 9. Select the correct answer.
    6·1 answer
  • True or False The two types of general construction projects are residential for homes or dwellings and commercial for a commerc
    7·1 answer
  • A line graph is a great tool for showing changes over time. Why is a line graph better than other graphs at showing this type of
    6·1 answer
  • Another name of computer program is
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!