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
Convert the following numbers. (Please show all steps; no marks will be awarded if no steps are shown) [1.5 x 4 = 6 marks]
katen-ka-za [31]

Answer:

i. 10210212

ii. 100 101 001 in BASE 2

iii. 46.4631

iv. 12.453125

Explanation:

i. Converting to base 10 we get

=  10 x 162 + 13 x 161 + 9 x 160 = 2777

Converting to base 10 we get  =

2777/3 = 925 with remainder 2

925/3 = 308 with remainder 1

308/3 = 102 with remainder 2

102/3 = 34 with remainder 0

34/3 = 11 with remainder 1

11/3 = 3 with remainder 2

3/3 = 1 with remainder 0

1/3 = 0 with remainder 1

Hence the Answer is 10210212

ii. = Octal is taken in pair of 3 bits , Writing binary of each number in 3 bits we get  = 100 101 001 in BASE 2

iii. = 1 x 52 + 2 x 51 + 3 x 50 + 3 x 5-1   = 38.6 in decimal

Converting to Octal we get

38 /8 = 4 with remainder 6

4 /8 = 0 with remainder 4

.6 x 8 =  4.8

.8 x 8 = 6.4

46.4631

iv. = 1x 81 + 4 x 80 + 3 x 8-1 + 5 x 8-2   = 12.453125

Check here for Free courses about IT and Management www.eacademy.lk

4 0
3 years ago
In what way, if any, can your social media presence affect your chances of getting a job in social media?
Leno4ka [110]

Answer:

Your social media postings can help you secure a job too, not just it being effective in a bad way.

Explanation:

Your content can give hiring managers an overall idea of your personality, what you are passionate about, how you interact with people in group discussions and how previous colleagues feel about you through recommendations and so on. All of these give you an advantage in securing a job.

7 0
2 years ago
According to the Modern Language Association (MLA) style guidelines, which citation is formatted correctly?
aalyn [17]
A) Marian Shelby. “The Fall of Rome.” Military Forces. n.p., 11 Mar 2009. Web.
14 Oct 2012.
4 0
3 years ago
Read 2 more answers
The leader of the team wants to do everything him or herself. They have a very big ego and are difficult to work with. What is t
JulijaS [17]

Answer:

The problem is the team leader thinks he/she is better than other team members?

Explanation:

He/She thinks or to show that no other team leader is as good as him/her.

7 0
3 years ago
All of the following are examples of software, except:
Bezzdna [24]
Speakers is your answer
7 0
3 years ago
Read 2 more answers
Other questions:
  • How does technology influence the development of personal and public identity?
    13·1 answer
  • Discuss FOUR challenges that have an impact on domestic tourism
    6·1 answer
  • What is the meaning of the phrase the video has gone viral
    9·2 answers
  • 5. ADD A STATEMENT OR STATEMENTS to the program on the following page (including constant and/or variable declarations if you wa
    6·1 answer
  • Radar devices are used by law enforcement to be sure that individuals are driving safely. They tell the officer how fast the veh
    12·1 answer
  • URLs are the global ______ of resources on the Internet.
    12·2 answers
  • Search engines enable you to
    12·1 answer
  • Which of the following is an advantage of using
    6·2 answers
  • Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. please select the
    13·1 answer
  • Enter the database function in cell i6 that determines the average salary of all full-time employees with at least one dependant
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!