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
ipn [44]
3 years ago
9

To find all the prime numbers less than or equal to a given integer n by Eratosthenes' method: 1. Create a list of consecutive i

ntegers from two to n: (2, 3, 4, ..., n), 2. Initially, let p equal 2, the first prime number, 3. While enumerating all multiples of p starting from p2, strike them off from the original list, 4. Find the first number remaining on the list after p (it's the next prime); let p equal this number, 5. Repeat steps 3 and 4 until p2 is greater than n. 6. All the remaining numbers in the list are prime.

Computers and Technology
1 answer:
natta225 [31]3 years ago
7 0

Answer:

I am writing a Python program:

def Eratosthenes(n):  

   primeNo = [True for i in range(n+1)]  # this is a boolean array

   p = 2  # the first prime number is initialized as 2

   while (p * p <= n):     # enumerates all multiples of p

       if (primeNo[p] == True):                

           for i in range(p * p, n+1, p):  #update multiples

               primeNo[i] = False

       p = p + 1        

   for p in range(2, n):   #display all the prime numbers

       if primeNo[p]:  

           print(p),    

def main():     #to take value of n from user and display prime numbers #less than or equal to n by calling Eratosthenes method

   n= int(input("Enter an integer n: "))

   print("The prime numbers less than or equal to",n, "are: ")  

   Eratosthenes(n)      

main()      

Explanation:

The program contains a Boolean type array primeNo that is initialized by True which means that any value i in prime array will be true if i is a prime otherwise it will be false. The while loop keeps enumerating all multiples of p starting from 2, and striking them off from the original array list and for loops keep updating the multiples. This process will continue till the p is greater than n.  The last for loop displays all the prime numbers less than or equal to n which is input by user. main() function prompts user to enter the value of integer n and then calls Eratosthenes() function to print all the prime numbers less than or equal to a given integer n.

   

You might be interested in
You often need to have several applications open at the same time. Which requirement is related to this need?
Musya8 [376]

Answer:

processor speed is the answer but not sure

5 0
3 years ago
When pasting a circle drawn by the presentation software drawing tool into a spreadsheet, that circle will go into the selected
ivann1987 [24]
The answer is ............................ False
6 0
3 years ago
Read 2 more answers
What is x squared times b squared
Pie

Answer:

x^2 * b^2

Explanation:

Like 3 squared times 2 squared is 3*3*2*2. Similarly the expression given in the question is equal to x*x*b*b. And that explains what is mentioned in question.

3 0
3 years ago
Why is it important not to leave your personal information on a public computer?
zheka24 [161]

Answer:

B. Someone can steal the information and hurt you.

Explanation:

People can hack into your accounts using your informations and spread hurtful things that can make people hurt. The people will think that you posted this (even if you didn't) and blame you.

7 0
2 years ago
Discuss operations of vectors in computer graphics?
Allushta [10]

Answer:

  In the computer graphics, the vectors are basically used to compose various type of components. In the computer graphics it is basically known as vector graphics and it is composed of various types of components.

The operation of the vector in the computer vector is that it is basically used to create the digital images by the use of mathematical statement and command.

It is used to place the lines and the shape in the two- dimension and three- dimension spaces. IN the computer graphics, vectors are also used to represent the particular direction of the various objects.

6 0
3 years ago
Other questions:
  • Bit rate is a measure of how many bits of data are transmitted per second. Compared to videos with a higher bit rate, the same v
    13·1 answer
  • Select the correct answer. Steve wants to change shooting and exposure settings while on his photo shoot. Which camera part will
    7·2 answers
  • Mihaela I. Croitoru – Utilizarea calculatorului personal Microsoft Word dau coroana
    14·1 answer
  • Which of the following is true regarding data analysis? a. Disciplines and professions do not provide guidance on data analysis.
    6·2 answers
  • Which command would you use to swap the words hither and yon on any line with any number of words between them? (You need not wo
    5·1 answer
  • What is the build in libary function to compare two strings?​
    15·1 answer
  • According to programming best practices, how should you handle code that needs to be repeated several times in a program?
    6·1 answer
  • How are digital and analog data similar? How are they different?
    15·1 answer
  • What are the tools in creating an animation?
    7·1 answer
  • True or false. The send e-mail feature, listed under tools, will allow you to send an e-mail to your instructor and to fellow st
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!